Hello! I'm trying to run the assembled bundle, but I get the following error:

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] 

I use apache camel , camel-mail and apache felix plugin . My pom.xml looks like this:

  <?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> 

As I understood from the glass, I need to add the package 'sun.misc' to 'org.osgi.framework.system.packages.extra' , but I don’t understand how to do it. Please tell me how to solve this problem and why is this happening?

    1 answer 1

    In the configuration file of the framework (for example, for Felix it is config.properties , for Equinox - config.ini ) write the necessary packages in the style:

     org.osgi.framework.system.packages.extra=\ sun.misc,\ some.package1,\ some.package2 

    For Felix, I know an additional way to solve it: go inside felix.jar and enter the packages in default.properties under the correct version of the Java machine.

    It is also almost always possible to find the necessary library and arrange it in the OSGi bundle either by writing the manifest manually, or by repackaging with some builder, or by using specials. utilities.