从bndtools / eclipse运行时出现OSGi Netty / Vertx错误

时间:2017-01-08 15:18:00

标签: maven osgi vert.x bnd bndtools

我正在尝试在OSGi(bndtools / eclipse)下运行vertx并从底层Netty获取此错误消息。

我正在使用vertx 3.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:

```

@Override
public void start(BundleContext bc) throws Exception {
   Vertx vertx = Vertx.vertx();

```

在标准的bndtools模板(无maven)中,这很好用。我不确定我是否可以在同一个项目中混合使用这两种模式,我更喜欢坚持使用maven格式。

修改

我从主要的Paremus项目hello示例中创建了这个示例项目,以演示我在Vert.x&amp; OSGi的 https://github.com/gadieichhorn/hello-examples/tree/hello-1.13.x

编辑2

我将Vertx初始化移动到服务(而非bundle激活器),现在我收到了更详细的错误。

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)

任何帮助表示赞赏

1 个答案:

答案 0 :(得分:1)

这是因为“PlatformDependent0”导入“sun.misc”。

您可以通过设置"org.osgi.framework.system.packages.extra=sun.misc"

来解决此问题

编辑1:

我以这种方式启动OSGi框架(Apache Felix):

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 ...)

隐式完成的