我已经使用以下三个包进行了申请
myservice-api
de.myservice.api.model.MyObject
de.myservice.api.services.MyService
void save(MyObject o)
myservice-impl
MyService
的实现,并通过DOSGi frontend
只是通过蓝图引用MyService
实施并调用save
函数我使用Apache Cellar功能创建了一个集群,在不同的机器上有两个Karaf服务器。捆绑包的部署方式如下,并显示状态Active
:
myservice-api
frontend
myservice-api
myservice-impl
使用cluster:list-nodes
时,显示已设置群集,使用cluster:service-list
我可以看到我的服务由machine002提供:
Service Class | Provider Node
-----------------------------------------------------------------
de.myservice.api.services.MyService | machine002.company.int:5701
OSGi链接和内容有效,但当frontend
尝试使用save
函数时,我在服务提供实例machine002
上收到以下异常:
2017-03-14 12:55:02,250 | WARN | pool-65-thread-1 | QueueConsumer | 328 - org.apache.karaf.cellar.hazelcast - 4.0.3 |
CELLAR HAZELCAST: consumer task failed to poll the queue com.hazelcast.nio.serialization.HazelcastSerializationException: java.lang.ClassNotFoundException: de.myservice.api.model.MyObject
at com.hazelcast.internal.serialization.impl.JavaDefaultSerializers$JavaSerializer.read(JavaDefaultSerializers.java:224)[322:com.hazelcast:3.7.2]
at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:46)[322:com.hazelcast:3.7.2]
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:172)[322:com.hazelcast:3.7.2]
at com.hazelcast.spi.impl.operationservice.impl.InvocationFuture.resolve(InvocationFuture.java:103)[322:com.hazelcast:3.7.2]
at com.hazelcast.spi.impl.operationservice.impl.InvocationFuture.resolveAndThrow(InvocationFuture.java:74)[322:com.hazelcast:3.7.2]
at com.hazelcast.spi.impl.AbstractInvocationFuture.get(AbstractInvocationFuture.java:158)[322:com.hazelcast:3.7.2]
at com.hazelcast.collection.impl.queue.QueueProxySupport.invokeAndGet(QueueProxySupport.java:177)[322:com.hazelcast:3.7.2]
at com.hazelcast.collection.impl.queue.QueueProxySupport.pollInternal(QueueProxySupport.java:124)[322:com.hazelcast:3.7.2]
at com.hazelcast.collection.impl.queue.QueueProxyImpl.poll(QueueProxyImpl.java:88)[322:com.hazelcast:3.7.2]
at org.apache.karaf.cellar.hazelcast.QueueConsumer.run(QueueConsumer.java:93)[328:org.apache.karaf.cellar.hazelcast:4.0.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_45]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_45]
Caused by: java.lang.ClassNotFoundException: de.myservice.api.model.MyObject
at org.apache.karaf.cellar.core.utils.CombinedClassLoader.findClass(CombinedClassLoader.java:79)[326:org.apache.karaf.cellar.core:4.0.3]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)[:1.8.0_45]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_45]
at com.hazelcast.nio.ClassLoaderUtil.tryLoadClass(ClassLoaderUtil.java:151)
at com.hazelcast.nio.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:120)
at com.hazelcast.nio.IOUtil$ClassLoaderAwareObjectInputStream.resolveClass(IOUtil.java:358)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1613)[:1.8.0_45]
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)[:1.8.0_45]
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774)[:1.8.0_45]
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)[:1.8.0_45]
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)[:1.8.0_45]
at java.util.LinkedList.readObject(LinkedList.java:1149)[:1.8.0_45]
at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497)[:1.8.0_45]
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)[:1.8.0_45]
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1896)[:1.8.0_45]
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)[:1.8.0_45]
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)[:1.8.0_45]
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)[:1.8.0_45]
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1918)[:1.8.0_45]
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)[:1.8.0_45]
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)[:1.8.0_45]
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)[:1.8.0_45]
at com.hazelcast.internal.serialization.impl.JavaDefaultSerializers$JavaSerializer.read(JavaDefaultSerializers.java:219)[322:com.hazelcast:3.7.2]
... 12 more
myservice-api
捆绑包部署在两台机器上,因此该类应该可用 - 我是否还需要配置其他内容,以便使用hazelcast知道从哪里获取类/ de序列化?
答案 0 :(得分:0)
看起来你的api包实际上没有导出所需的包。 因此,请确保它确实如此。既然它正在“服务器”方面工作, 我确定您的实现包可能包含这些API包。因此,请确保您的捆绑包的导出/导入等正确无误。