我从包中开始这个例外:
java.lang.NoClassDefFoundError: gnu/io/SerialPortEventListener
我的捆绑包正在使用此捆绑包:[1] enocean库 enocean库[1]正在使用rxtx库,我在项目中将其作为包添加,rxtx包含未找到的类:" SerialPortEventListener"
EnOcean库[1]将包gnu.io声明为导入包,并且包rxtx正在导出包,包版本是相同的。
我发现如果该类依赖于另一个无法找到的类,则会出现错误NoClassDefFoundError,但是SerialPortEventListener是一个来自EventListener的接口。
无法找出昼夜平分点无法找到它的原因。
!ENTRY org.eclipse.equinox.ds 4 0 2015-06-22 12:55:02.616
!MESSAGE [SCR] Exception while activating instance org.eclipse.kura.binding.enocean.EnOcean@79d49d of component org.eclipse.kura.binding.enocean
!STACK 0
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)
Caused by: java.lang.NoClassDefFoundError: gnu/io/SerialPortEventListener
at org.eclipse.kura.binding.enocean.EnOcean.activate(EnOcean.java:27)
... 15 more
Caused by: java.lang.ClassNotFoundException: gnu.io.SerialPortEventListener
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 16 more
Root exception:
java.lang.NoClassDefFoundError: gnu/io/SerialPortEventListener
at org.eclipse.kura.binding.enocean.EnOcean.activate(EnOcean.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)
Caused by: java.lang.ClassNotFoundException: gnu.io.SerialPortEventListener
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 16 more
更新: 我尝试了一种新方法,我将EnOcean库的源文件复制到我的包中,这些来源使用了库[2]思考
我将库换成了一个捆绑包(使用eclipse:从退出的档案创建捆绑包)然后我启动了它(捆绑包启动没有错误)
我从包中导入了所需的包,但是启动我的包会导致相同的错误,但在Reflections包中
我启动了捆绑番石榴,因为它是导致错误的那个但没有成功,我添加了反射所需的包guava [3]的包作为导入的包并且再次没有成功:( 这是错误:
Root exception:
java.lang.NoClassDefFoundError: com/google/common/collect/Lists
at org.reflections.util.FilterBuilder.<init>(FilterBuilder.java:24)
at org.reflections.scanners.SubTypesScanner.<init>(SubTypesScanner.java:19)
at org.reflections.scanners.SubTypesScanner.<init>(SubTypesScanner.java:12)
at org.reflections.util.ConfigurationBuilder.<init>(ConfigurationBuilder.java:53)
at EnOcean.EEP.EEPRegistry.<init>(EEPRegistry.java:26)
at EnOcean.EEP.EEPRegistry.getInstance(EEPRegistry.java:53)
at EnOceanLibrary.communication.EnJConnection.initCommon(EnJConnection.java:205)
at EnOceanLibrary.communication.EnJConnection.<init>(EnJConnection.java:154)
at org.eclipse.kura.binding.enocean.EnOcean.activate(EnOcean.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)
提前感谢您的帮助!
[1] https://github.com/dog-gateway/enj-library
[2] http://mvnrepository.com/artifact/org.reflections/reflections/0.9.9-RC2
[3] http://mvnrepository.com/artifact/com.google.guava/guava/15.0
答案 0 :(得分:0)
异常似乎来自org.eclipse.kura.binding.enocean
捆绑,而不是来自EnJ-Library捆绑。
org.eclipse.kura.binding.enocean
导入包gnu.io
吗?
答案 1 :(得分:0)
@Neil Barlett:感谢您的回复!
最后,我在libs目录中添加了reflections.jar,并将其添加到Bundle类路径中。 我在我的捆绑包中导入了com.google.common.collect。 这次它有效,不确定它是否是最佳解决方案,但似乎当我使用eclipse将reflections.jar包装在一个捆绑包中时,它无法正常工作。