Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法运行OSGI捆绑包_Java_Maven_Apache Camel_Apache Felix_Osgi Bundle - Fatal编程技术网

Java 无法运行OSGI捆绑包

Java 无法运行OSGI捆绑包,java,maven,apache-camel,apache-felix,osgi-bundle,Java,Maven,Apache Camel,Apache Felix,Osgi Bundle,我正在尝试收集捆绑包,但出现错误: Caused by: java.lang.ClassNotFoundException: *** Package 'sun.misc' is not imported by bundle org.apache.camel.camel-core [12], nor is there any bundle that exports package 'sun.misc'. However, the class 'sun.misc.Unsafe' is availab

我正在尝试收集捆绑包,但出现错误:

Caused by: java.lang.ClassNotFoundException: *** Package 'sun.misc' is not imported by bundle org.apache.camel.camel-core [12], nor is there any bundle that exports package 'sun.misc'. However, the class 'sun.misc.Unsafe' is available from the system class loader. There are two fixes: 1) Add package 'sun.misc' to the 'org.osgi.framework.system.packages.extra' property and modify bundle org.apache.camel.camel-core [12] to import this package; this causes the system bundle to export class path packages. 2) Add package 'sun.misc' to the 'org.osgi.framework.bootdelegation' property; a library or VM bug can cause classes to be loaded by the wrong class loader. The first approach is preferable for preserving modularity. ***
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2031)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 17 more
Caused by: java.lang.ClassNotFoundException: sun.misc.Unsafe not found by org.apache.camel.camel-core [12]
我正在使用
apachecamel
camel-mail
apachefelix插件

My
pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0              
http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.camel.mail</groupId>
<artifactId>com.camel.mail</artifactId>
<version>1.0</version>

<dependencies>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-mail</artifactId>
        <version>2.17.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core-osgi</artifactId>
        <version>2.17.1</version>
    </dependency>

    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.core</artifactId>
        <version>6.0.0</version>
    </dependency>

    <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.osgi.compendium</artifactId>
        <version>1.4.0</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.21</version>
    </dependency>

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.21</version>
    </dependency>
</dependencies>

<build>
    <plugins>

        <plugin>
            <inherited>true</inherited>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <executions>
                <execution>
                    <id>osgi-bundle</id>
                    <goals>
                        <goal>bundle</goal>
                    </goals>
                    <phase>package</phase>
                    <configuration>
                        <instructions>
                            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                            <Bundle-Version>1.0</Bundle-Version>
                            <Bundle-Activator>com.camel.mail.Activator</Bundle-Activator>
                            <Import-Package>
                                *;resolution:=optional
                            </Import-Package>
                        </instructions>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

4.0.0
com.camel.mail
com.camel.mail
1
org.apache.camel
骆驼邮件
2.17.1
org.apache.camel
驼芯osgi
2.17.1
org.osgi
org.osgi.core
6.0.0
org.apache.felix
org.osgi.compendium
1.4.0
org.slf4j
slf4j api
1.7.21
log4j
log4j
1.2.17
org.slf4j
slf4j简单
1.7.21
真的
org.apache.felix
maven捆绑插件
osgi束
捆
包裹
${project.artifactId}
1
com.camel.mail.Activator
*;分辨率:=可选

据我所知,我需要将包
'sun.misc'
添加到
'org.osgi.framework.system.packages.extra'
,但我不知道如何做


请帮助我解决此问题。

尝试将“sun.*”添加到org.osgi.framework.bootdegration属性。

您是尝试在Karaf中运行Camel,还是?我尝试在Apache ServiceMix中运行,但出现错误:
错误:Bundle com.Camel.mail[223]错误启动jardir:D:\Programs\Apache-ServiceMix-7.0.0.M2\deploy\classes(org.osgi.framework.BundleException:bundle com.camel.mail[223]中的Activator启动错误)java.lang.NoClassDefFoundError:org/apache/camel/CamelContext位于java.lang.Class.getDeclaredConstructors0(本机方法)…原因:java.lang.ClassNotFoundException:org.apache.camel.CamelContext未被com.camel.mail[223]找到。