gpt4 book ai didi

java - 在 OSGi 包中反序列化时发生 ClassNotFoundException

转载 作者:行者123 更新时间:2023-11-29 09:15:30 28 4
gpt4 key购买 nike

在 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() 方法行bundle 确实没有效果。我可能缺少什么?

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]

最佳答案

您是否尝试在您的包的 MANIFEST.MF 中添加:

Import-Package: net.beaconcontroller.cluster

关于java - 在 OSGi 包中反序列化时发生 ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9773144/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com