【问题标题】:ERROR sun.misc when upgrade to karaf 4.X from karaf 3.X从 karaf 3.X 升级到 karaf 4.X 时出现错误 sun.misc
【发布时间】:2018-12-27 21:50:32
【问题描述】:

我们遇到了阻碍我们的问题。 我们在 Apache karaf 3.0.3、cellar 3.0.3 中的项目运行良好。现在我们升级到 Apache karaf 4.2.0 和 Apache cellar 4.1.0。我看到了这个错误

[activator-1-thread-2] 错误 org.apache.karaf.features.internal.service.BootFeaturesInstaller - 安装引导功能时出错 org.osgi.service.resolver.ResolutionException:无法解析根: 缺少需求 [root] osgi.identity; osgi.identity=OUR_FEATURE; 类型=karaf.feature;版本="[18.12.4,18.12.4]"; filter:="(&(osgi.identity=OUR_FEATURE)(type=karaf.feature)(version>=18.12.4)(version[引起:无法解析 com.hazelcast/3.8.1:缺少要求 [com.hazelcast/3.8.1] osgi.wiring.package; filter:="(osgi.wiring.package=sun.misc)"]]]]]*
*在 org.apache.felix.resolver.ResolutionError.toException(ResolutionError.java:42) ~[?:?] 在 org.apache.felix.resolver.ResolverImpl.doResolve(ResolverImpl.java:391) ~[?:?] 在 org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:377) ~[?:?] 在 org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:331) ~[?:?] 在 org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:248) ~[?:?] 在 org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:388) ~[?:?] 在 org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1025) ~[?:?] 在 org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:964) ~[?:?] 在 org.apache.karaf.features.internal.service.FeaturesServiceImpl$$Lambda$75/1531068986.call(未知 来源)~[?:?] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:?] 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:?] 在 java.lang.Thread.run(Thread.java:745) [?:?]

正如我们所见,错误来自 com.hazelcast,版本 3.8.1

确实,过去我们使用 karaf cellar 和 karaf 3.0.3,他们使用 com.hazelcast/hazelcast/version 3.4。 2 (https://mvnrepository.com/artifact/com.hazelcast/hazelcast/3.4.2)

现在有了 karaf 4.2.0 和 cellar 4.1.0,他们使用 com.hazelcast/hazelcast-all/3.8.1 https://mvnrepository.com/artifact/com.hazelcast/hazelcast-all/3.8.1 而这个版本导致了这个错误

这是我们的 features.xml 文件的内容

<repository>mvn:org.apache.karaf.cellar/apache-karaf-cellar/4.1.0/xml/features</repository>
<feature name="OUR_FEATURE" version="18.12.4" description="Our description">
    <feature>cellar</feature>
    <feature version="${project.version}">other_features</feature>
</feature>

安装后我们尝试在目标目录中搜索(mvn clean install)并在目标文件夹中找到这些功能

<feature name="OUR_FEATURE" version="18.12.4" description="Our description">
    <feature>cellar</feature>
    <feature version="18.12.4">other_features</feature>
</feature>

<feature name="cellar" description="Karaf clustering" version="4.1.0">
    <feature dependency="true">cellar-hazelcast</feature>
    <feature>cellar-shell</feature>
    <feature>cellar-config</feature>
    <feature>cellar-bundle</feature>
    <feature>cellar-features</feature>
    <feature>cellar-kar</feature>
    <requirement>
        karaf.cellar.provider
    </requirement>
</feature>

<feature name="cellar" description="Karaf clustering" version="4.1.0">
    <feature dependency="true">cellar-hazelcast</feature>
    <feature>cellar-shell</feature>
    <feature>cellar-config</feature>
    <feature>cellar-bundle</feature>
    <feature>cellar-features</feature>
    <feature>cellar-kar</feature>
    <requirement>
        karaf.cellar.provider
    </requirement>
</feature>

<feature name="cellar-hazelcast" description="Cellar implementation based on Hazelcast" version="4.1.0">
    <feature version="3.8.1">hazelcast</feature>
    <feature version="4.1.0">cellar-core</feature>
    <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.hazelcast/4.1.0</bundle>
    <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.utils/4.1.0</bundle>
    <capability>
        karaf.cellar.provider;provider:=hazelcast
    </capability>
</feature>

<feature name="hazelcast" description="In memory data grid" version="3.8.1">
    <configfile finalname="/etc/hazelcast.xml">mvn:org.apache.karaf.cellar/apache-karaf-cellar/4.1.0/xml/hazelcast</configfile>
    <bundle>mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
    <bundle>mvn:com.eclipsesource.minimal-json/minimal-json/0.9.2</bundle>
    <bundle>mvn:com.hazelcast/hazelcast-all/3.8.1</bundle>
</feature>

在我们的 src/main/distribution/etc/config.properties 中,我们已经有以下配置: org.osgi.framework.system.packages.extra=sun.misc

org.osgi.framework.bootdelegation=org.apache.karaf.jaas.boot,org.apache.karaf.jaas.boot.principal,org.apache.karaf.management.boot,sun.,com .sun.,javax.transaction,javax.transaction.,javax.xml.crypto,javax.xml.crypto.

org.osgi.framework.executionenvironment=J2SE-1.8,JavaSE-1.8,J2SE-1.7,JavaSE-1.7,J2SE-1.6,JavaSE-1.6,J2SE-1.5,JavaSE-1.5,J2SE-1.4, JavaSE-1.4,J2SE-1.3,JavaSE-1.3,J2SE-1.2,,JavaSE-1.2,CDC-1.1/Foundation-1.1,CDC-1.0/Foundation-1.0,J2ME,OSGi/Minimum-1.1,OSGi/Minimum-1.0

在我们的 src/main/distribution/etc/custom.properties 中,我们有以下配置:

karaf.systemBundlesStartLevel=50 org.osgi.framework.system.packages.extra = org.apache.karaf.branding

请帮助我们解决这个问题。

非常感谢

【问题讨论】:

    标签: osgi hazelcast apache-karaf osgi-bundle karaf


    【解决方案1】:

    当包加载类但没有为它们定义 Import-Package 语句时使用引导委托。

    在您的情况下,hazelcast 有一个 Import-Package 声明。因此,要完成这项工作,您必须从系统捆绑包中导出包。

    为此,请编辑config.properties 并将sun.misc 添加到org.osgi.framework.system.packages.extra

    【讨论】:

    • 非常感谢您的回答。如您所见,我已经写过:“在我们的 src/main/distribution/etc/config.properties 中,我们已经有以下配置:org.osgi.framework.system.packages.extra=sun.misc” 但它不起作用.所以我尝试使用引导委托,它也不起作用
    • 从系统包中导出是唯一可行的方法。也许配置中有一个小错误,它没有被处理。我刚刚启动了一个普通的 karaf 4.2.0 并安装了事务功能和 hazelcast 包。它开箱即用。 sun.misc 包已经导出。
    • 感谢您的回答。你把你的config.properties放在哪里?我的目录布局类似于 my-deployement/pom.xml my-deployement/src/main/distribution/binaries/setenv my-deployement/src/main/distribution/etc my-deployement/src/main/distribution/filtered-resources这是 my-deployement/src/main/distribution/etc 文件夹中的文件列表: - config.properties、custom.properties、keys.properties、org.apache.cxf.osgi.cfg、org.apache.karaf.management .cfg、org.apache.karaf.shell.cfg、org.ops4j.pax.url.mvn.cfg、org.ops4j.pax.web.cfg、system.properties、user.properties
    • 这里是 my-deployement/src/main/distribution/etc 文件夹中的文件列表: - config.properties,custom.properties,keys.properties,org.apache.cxf.osgi.cfg , org.apache.karaf.management.cfg, org.apache.karaf.shell.cfg, org.ops4j.pax.url.mvn.cfg, org.ops4j.pax.web.cfg, system.properties, user.properties
    • 这里是 my-deployement/src/main/distribution/filtered-resources 中的文件列表:org.apache.karaf.cellar.groups.cfg, org.apache.karaf.cellar.node .cfg、org.apache.karaf.features.cfg、org.ops4j.pax.logging.cfg
    【解决方案2】:

    这是我的 config.properties 的提取

    org.osgi.framework.system.packages= \
     org.osgi.framework.startlevel;uses:="org.osgi.framework";version="1.0", \
     org.osgi.framework.wiring;uses:="org.osgi.framework";version="1.1", \
     org.osgi.framework.hooks.bundle;uses:="org.osgi.framework";version="1.1", \
     org.osgi.framework.hooks.service;uses:="org.osgi.framework";version="1.1", \
     org.osgi.framework.hooks.resolver;uses:="org.osgi.framework.wiring";version="1.0", \
     org.osgi.framework.launch;uses:="org.osgi.framework";version="1.1", \
     org.osgi.framework.namespace;uses:="org.osgi.resource";version="1.0", \
     org.osgi.framework;version="1.7", \
     org.osgi.framework.hooks.weaving;uses:="org.osgi.framework.wiring";version="1.0",\
     org.osgi.resource;version="1.0",org.osgi.service.url;version="1.0",\
     org.osgi.service.startlevel;uses:="org.osgi.framework";version="1.1",\
     org.osgi.service.packageadmin;uses:="org.osgi.framework";version="1.2",\
     org.osgi.service.url;version="1.0", \
     org.osgi.util.tracker;uses:="org.osgi.framework";version="1.5.1", \
     org.apache.karaf.jaas.boot;version="4.2.0", \
     org.apache.karaf.jaas.boot.principal;version="4.2.0", \
     org.apache.karaf.management.boot;version="4.2.0", \
     org.apache.karaf.version;version="4.2.0", \
     ${jre-${java.specification.version}}
    
    
    
    org.osgi.framework.system.packages.extra=sun.misc
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-12
      • 1970-01-01
      • 2016-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多