我试图在OSGi (bndtools/eclipse)下运行vertx,并从底层的Netty获取此错误消息。
我使用vertx3.3.3,在独立模式( maven )中使用bndtools,所以所有依赖项都是使用maven而不是标准bndtools (cnf)模板导入的。
17:00:05.935 [main] DEBUG io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework 17:00:05.938 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.level: simple 17:00:05.939 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.maxRecords: 4 17:00:05.971 [main] DEBUG io.netty.channel.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 8 17:00:05.993 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Buffer.address: available 17:00:05.994 [main] DEBUG io.netty.util.internal.PlatformDependent - Platform: Windows 17:00:05.994 [main] DEBUG io.netty.util.internal.PlatformDependent - Java version: 8 17:00:05.994 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.noUnsafe: false 17:00:05.995 [main] DEBUG io.netty.util.internal.PlatformDependent - maxDirectMemory: 3776970752 bytes (maybe) ! Failed to start bundle mybundle.vertx-2.0.0, exception activator error Could not initialize class io.netty.util.internal.PlatformDependent0 from: io.netty.util.internal.PlatformDependent:<clinit>#101
在我的bundle激活器中,我尝试使用静态方法创建一个新的vertx:
```javascript@Override
公共空启动(BundleContext bc)引发异常{
Vertx.vertx= Vertx.vertx();
在标准的bndtools模板(无maven)中,这很好。我不确定我能否将这两种模式混合在同一个项目中,我更愿意坚持使用maven格式。
编辑
我创建了这个从主Paremus项目hello示例中克隆的示例项目,以演示我在Vert.x & OSGi https://github.com/gadieichhorn/hello-examples/tree/hello-1.13.x中遇到的问题。
编辑2
我将Vertx初始化移到了一个服务(不是包激活器)上,现在我得到了一个更详细的错误。
ERROR: helloworld-web (6): [com.example.hello.web.VertxRegistrationService(0)] The start method has thrown an exception
java.lang.NoClassDefFoundError: Could not initialize class io.netty.util.internal.PlatformDependent0
at io.netty.util.internal.PlatformDependent.<clinit>(PlatformDependent.java:101)
at io.netty.util.ConstantPool.<init>(ConstantPool.java:32)
at io.netty.util.Signal$1.<init>(Signal.java:27)
at io.netty.util.Signal.<clinit>(Signal.java:27)
at io.netty.util.concurrent.DefaultPromise.<clinit>(DefaultPromise.java:42)
at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:36)
at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:58)
at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:47)
at io.netty.channel.MultithreadEventLoopGroup.<init>(MultithreadEventLoopGroup.java:58)
at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:77)
at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:72)
at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:59)
at io.vertx.core.impl.VertxImpl.<init>(VertxImpl.java:133)
at io.vertx.core.impl.VertxImpl.<init>(VertxImpl.java:122)
at io.vertx.core.impl.VertxImpl.<init>(VertxImpl.java:118)
at io.vertx.core.impl.VertxFactoryImpl.vertx(VertxFactoryImpl.java:34)
at io.vertx.core.Vertx.vertx(Vertx.java:80)
at com.example.hello.web.VertxRegistrationService.lambda$0(VertxRegistrationService.java:26)
at com.example.hello.web.TcclSwitch.executeWithTCCLSwitch(TcclSwitch.java:11)
at com.example.hello.web.VertxRegistrationService.start(VertxRegistrationService.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:222)
at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:37)
at org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:615)
at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:499)
at org.apache.felix.scr.impl.helper.ActivateMethod.invoke(ActivateMethod.java:295)
at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:302)
at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:113)
at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:866)
at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:833)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:724)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:399)
at org.apache.felix.scr.impl.config.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:676)
at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:339)
at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:360)
at org.apache.felix.scr.impl.Activator.access$000(Activator.java:53)
at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:260)
at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259)
at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:232)
at org.apache.felix.utils.extender.AbstractExtender.addingBundle(AbstractExtender.java:192)
at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:469)
at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:415)
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183)
at org.osgi.util.tracker.BundleTracker.open(BundleTracker.java:156)
at org.apache.felix.utils.extender.AbstractExtender.startTracking(AbstractExtender.java:150)
at org.apache.felix.utils.extender.AbstractExtender.doStart(AbstractExtender.java:142)
at org.apache.felix.scr.impl.Activator.doStart(Activator.java:170)
at org.apache.felix.utils.extender.AbstractExtender.start(AbstractExtender.java:114)
at org.apache.felix.scr.impl.Activator.restart(Activator.java:140)
at org.apache.felix.scr.impl.config.ScrConfiguration.configure(ScrConfiguration.java:215)
at org.apache.felix.scr.impl.config.ScrConfiguration.start(ScrConfiguration.java:136)
at org.apache.felix.scr.impl.Activator.start(Activator.java:110)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2226)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2144)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
at aQute.launcher.Launcher.update(Launcher.java:483)
at aQute.launcher.Launcher.activate(Launcher.java:382)
at aQute.launcher.Launcher.run(Launcher.java:276)
at aQute.launcher.Launcher.main(Launcher.java:133)感谢你的任何帮助
发布于 2017-02-28 22:40:58
这是因为"PlatformDependent0“导入了"sun.misc”。
您可以通过设置"org.osgi.framework.system.packages.extra=sun.misc"来解决这个问题。
编辑1:
我以这样的方式启动OSGi框架(Apache ):
Map<String, String> configProperties = Main.loadConfigProperties();
Main.copySystemProperties(configProperties);
configProperties.put("org.osgi.framework.system.packages.extra","sun.misc");
Framework fw = new Felix(configProperties);
fw.init();
AutoProcessor.process(configProperties, fw.getBundleContext());但是我想您可以直接将这个设置放在"felix.config.properties"文件中。
出现这些问题是因为sun.misc是私有的API。因此,您必须显式地将包添加为主包提供的额外包。它是为公共API隐式完成的(java.lang,java.util.)
https://stackoverflow.com/questions/41534228
复制相似问题