java - 预装 pax-jdbc-oracle 的自定义 Apache Karaf 4.0.4 发行版

标签 java oracle maven jdbc apache-karaf

我正在尝试构建一个带有一些预装功能的自定义 karaf 发行版,因为我们没有互联网来部署它。

这是我们的 pom:

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
     xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

<groupId>yolo.name.so</groupId>
<artifactId>karaf</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>karaf-assembly</packaging>

<properties>
    <karaf.version>4.0.4</karaf.version>
    <!-- Karaf Maven Plugin does not have to be same as Karaf Server version
         For example, Karaf Maven Plugin 3.0.2 has bug uploading to password protected Nexus Repo
         So I used Karaf Maven Plugin 3.0.3 to build a Karaf 3.0.2 Server -->
    <karaf.plugin.version>${karaf.version}</karaf.plugin.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.build.reportEncoding>UTF-8</project.build.reportEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>org.apache.karaf.features</groupId>
        <artifactId>framework</artifactId>
        <version>${karaf.version}</version>
        <type>kar</type>
    </dependency>
    <dependency>
        <groupId>org.apache.karaf.features</groupId>
        <artifactId>standard</artifactId>
        <version>${karaf.version}</version>
        <classifier>features</classifier>
        <type>xml</type>
       <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf.karaf</groupId>
        <artifactId>apache-cxf</artifactId>
        <version>3.1.4</version>
        <classifier>features</classifier>
        <type>xml</type>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.ops4j.pax.jdbc</groupId>
        <artifactId>pax-jdbc</artifactId>
        <version>0.7.0</version>
        <scope>provided</scope>
       </dependency>
    <dependency>
        <groupId>org.ops4j.pax.jdbc</groupId>
        <artifactId>pax-jdbc-oracle</artifactId>
        <version>0.7.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.karaf.features</groupId>
        <artifactId>enterprise</artifactId>
        <classifier>features</classifier>
        <type>xml</type>
        <version>${karaf.version}</version>
        <scope>runtime</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.karaf.tooling</groupId>
            <artifactId>karaf-maven-plugin</artifactId>
            <version>${karaf.plugin.version}</version>
            <extensions>true</extensions>
            <configuration>
                <!-- ignoreDependencyFlag is true forces plugin to also
                download feature dependent libraries -->
                <ignoreDependencyFlag>true</ignoreDependencyFlag>
                <finalName>${project.artifactId}</finalName>
                <bootFeatures>
                    <feature>bundle</feature>
                    <feature>config</feature>
                    <feature>diagnostic</feature>
                    <feature>deployer</feature>
                    <feature>feature</feature>
                    <feature>jaas</feature>
                    <feature>shell</feature>
                    <feature>log</feature>
                    <feature>management</feature>
                    <feature>package</feature>
                    <feature>shell-compat</feature>
                    <feature>ssh</feature>
                    <feature>system</feature>
                    <feature>wrap</feature>
                    <feature>instance</feature>
                    <feature>kar</feature>
                    <!-- custom features -->
                    <feature>war</feature>
                    <feature>jdbc</feature>
                    <feature>cxf</feature>
                    <feature>cxf-rs-description-swagger2</feature>
                    <feature>service</feature>
                    <feature>eventadmin</feature>
                </bootFeatures>
                <!-- installedFeatures only installs the libraries in the ${KARAF_HOME}/system directory
                     but the user will have to start it up manually via Karaf command line feature:install
                -->
                <installedFeatures>
                    <feature>pax-jdbc</feature>
                    <feature>pax-jdbc-oracle</feature>
                </installedFeatures>
                <archiveZip>true</archiveZip>
            </configuration>
        </plugin>
    </plugins>
</build>

我们总是收到以下错误:

feature:install pax-jdbc-oracle 
    org.apache.karaf.shell.core[org.apache.karaf.shell.support.ShellUtil] : Exception caught while executing command
    org.osgi.service.resolver.ResolutionException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=pax-jdbc-oracle; type=karaf.feature; version="[0.7.0,0.7.0]"; filter:="(&(osgi.identity=pax-jdbc-oracle)(type=karaf.feature)(version>=0.7.0)(version<=0.7.0))" [caused by: Unable to resolve pax-jdbc-oracle/0.7.0: missing requirement [pax-jdbc-oracle/0.7.0] osgi.identity; osgi.identity=org.ops4j.pax.jdbc.oracle; type=osgi.bundle; version="[0.7.0,0.7.0]"; resolution:=mandatory [caused by: Unable to resolve org.ops4j.pax.jdbc.oracle/0.7.0: missing requirement [org.ops4j.pax.jdbc.oracle/0.7.0] osgi.wiring.package; filter:="(osgi.wiring.package=oracle.jdbc.pool)"]]
        at org.apache.felix.resolver.ResolutionError.toException(ResolutionError.java:42)
        at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:235)
        at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:158)
        at org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:216)
        at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:263)
        at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1089)
        at org.apache.karaf.features.internal.service.FeaturesServiceImpl$1.call(FeaturesServiceImpl.java:985)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
    Error executing command: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=pax-jdbc-oracle; type=karaf.feature; version="[0.7.0,0.7.0]"; filter:="(&(osgi.identity=pax-jdbc-oracle)(type=karaf.feature)(version>=0.7.0)(version<=0.7.0))" [caused by: Unable to resolve pax-jdbc-oracle/0.7.0: missing requirement [pax-jdbc-oracle/0.7.0] osgi.identity; osgi.identity=org.ops4j.pax.jdbc.oracle; type=osgi.bundle; version="[0.7.0,0.7.0]"; resolution:=mandatory [caused by: Unable to resolve org.ops4j.pax.jdbc.oracle/0.7.0: missing requirement [org.ops4j.pax.jdbc.oracle/0.7.0] osgi.wiring.package; filter:="(osgi.wiring.package=oracle.jdbc.pool)"]]

我们希望预安装此功能,但不知何故,将其放在 bootFeatures 或InstalledFeatures 下并不重要。

提供的范围/运行时也并不重要。

最佳答案

由于许可原因,pax-jdbc-oracle 功能无法打包 oracle jdbc 驱动程序。您必须提供自己的副本,并将其包含在您的发行版中。该驱动程序无法在 Maven Central 中访问,并且没有许可证就无法下载。

参见:https://ops4j1.jira.com/wiki/display/PAXJDBC/Oracle+driver+adapter

关于java - 预装 pax-jdbc-oracle 的自定义 Apache Karaf 4.0.4 发行版,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35795534/

相关文章:

java - 当使用 read_osm() 在 R 中的 tmap 的绘图模式下显示 basemap 时,我该怎么做才能不再出现 jcall 错误?

java - Oracle sql随机数种子

maven - travis-ci 中构建的 Github Gradle 项目如何访问通常在我的本地 Maven 存储库中找到的依赖项?

java - 如何切换maven项目?

java - Testng 不会单独计算数据提供者测试

java - 为什么 setVisible() 会删除我的组件?

oracle - Where 子句中的 If 语句

java.sql.SQLException : ORA-00900: invalid SQL statement in Ecllips

java - 使用 Swing 应用程序运行时部署 tomcat

java - Guice 风格的服务定位器