在OSGi包中反序列化时ClassNotFoundException

时间:2012-03-19 15:38:12

标签: java osgi classnotfoundexception jgroups

在OSGi包(称为net.beaconcontroller.cluster)中,我有org.jgroups.blocks.ReplicatedHashMap类型<Long, net.beaconcontroller.cluster.ControllerInfo>。问题是,在调度期间(即远程端ControllerInfo的反序列化)JGroups抱怨ClassNotFoundException。 (附加了堆栈跟踪。)添加

Thread.currentThread().setContextClassLoader(Cluster.class.getClassLoader())

net.beaconcontroller.cluster包的startUp()方法的行确实没有效果。我可能会缺少什么?

Caused by: java.lang.ClassNotFoundException: net.beaconcontroller.cluster.ControllerInfo
        at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506) ~[na:na]
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422) ~[na:na]
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410) ~[na:na]
        at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) ~[na:na]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ~[na:1.6.0_30]
        at java.lang.Class.forName0(Native Method) ~[na:1.6.0_30]
        at java.lang.Class.forName(Class.java:247) ~[na:1.6.0_30]
        at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:603) ~[na:1.6.0_30]
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574) ~[na:1.6.0_30]
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495) ~[na:1.6.0_30]
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731) ~[na:1.6.0_30]
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328) ~[na:1.6.0_30]
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350) ~[na:1.6.0_30]
        at java.util.HashMap.readObject(HashMap.java:1030) ~[na:1.6.0_30]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_30]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_30]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_30]
        at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_30]
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974) ~[na:1.6.0_30]
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1848) ~[na:1.6.0_30]
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752) ~[na:1.6.0_30]
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328) ~[na:1.6.0_30]
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350) ~[na:1.6.0_30]
        at org.jgroups.blocks.ReplicatedHashMap.setState(ReplicatedHashMap.java:540) ~[na:na]
        at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.handleUpEvent(MessageDispatcher.java:497) ~[na:na]
        at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.up(MessageDispatcher.java:558) ~[na:na]

1 个答案:

答案 0 :(得分:0)

您是否尝试添加捆绑包的MANIFEST.MF:

Import-Package: net.beaconcontroller.cluster