我遇到了一个问题,当 android 上的 Mina 客户端尝试反序列化一个对象时,发生了 ClassNotFoundException。堆栈如下图所示:
04-13 01:56:21.521:
04-13 01:56:21.521: D/RegisterTask(299): Caused by: org.apache.mina.filter.codec.ProtocolDecoderException: java.lang.ClassNotFoundException: com.geoxy.message.agent.user.RegisterResponse (Hexdump: 12 00 00 2A 00 00 00 DA 12 04 00 02 00 00 00 D2 AC ED 00 05 73 72 01 00 2D 63 6F 6D 2E 67 65 6F 78 79 2E 6D 65 73 73 61 67 65 2E 61 67 65 6E 74 2E 75 73 65 72 2E 52 65 67 69 73 74 65 72 52 65 73 70 6F 6E 73 65 78 72 01 00 1D 63 6F 6D 2E 67 65 6F 78 79 2E 63 6F 6D 6D 6F 6E 2E 52 65 73 70 6F 6E 73 65 42 61 73 65 78 72 01 00 1C 63 6F 6D 2E 67 65 6F 78 79 2E 63 6F 6D 6D 6F 6E 2E 4D 65 73 73 61 67 65 42 61 73 65 78 70 12 04 00 02 73 72 01 00 2D 63 6F 6D 2E 67 65 6F 78 79 2E 63 6F 6D 6D 6F 6E 2E 4D 65 73 73 61 67 65 42 61 73 65 24 4D 65 73 73 61 67 65 53 69 67 6E 61 74 75 72 65 78 70 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 00 71 00 7E 00 03 00 70 00 00 00 00 00 00 00 03)
04-13 01:56:21.521: D/RegisterTask(299): at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:251)
04-13 01:56:21.521: D/RegisterTask(299): at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
04-13 01:56:21.521: D/RegisterTask(299): at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$5(DefaultIoFilterChain.java:429)
04-13 01:56:21.521: D/RegisterTask(299): at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)
04-13 01:56:21.521: D/RegisterTask(299): at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119)
04-13 01:56:21.521: D/RegisterTask(299): at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
04-13 01:56:21.521: D/RegisterTask(299): at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426)
04-13 01:56:21.521: D/RegisterTask(299): at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:715)
04-13 01:56:21.521: D/RegisterTask(299): at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:668)
04-13 01:56:21.521: D/RegisterTask(299): at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:657)
04-13 01:56:21.521: D/RegisterTask(299): at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$9(AbstractPollingIoProcessor.java:654)
04-13 01:56:21.521: D/RegisterTask(299): at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1141)
04-13 01:56:21.521: D/RegisterTask(299): at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
但是我不明白,缺少的类“com.geoxy.message.agent.user.RegisterResponse”实际上包含在message.jar中,我已经将message.jar放在了项目构建路径下。(并且服务器也使用相同的 message.jar 来序列化类。)
而且我还检查了项目.classpath,它包含了message.jar。
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="libs/dumpcatcher.jar"/>
<classpathentry kind="lib" path="libs/common-0.1.jar"/>
<classpathentry kind="lib" path="libs/log4j-1.2.16.jar"/>
<classpathentry kind="lib" path="libs/slf4j-android-1.6.1-RC1.jar"/>
<classpathentry kind="lib" path="libs/message-0.1.jar"/> <!---here is it.-->
<classpathentry kind="lib" path="libs/mina-core-2.0.4.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
请帮忙,还有其他原因导致ClassNotFoundException吗?非常感谢。我还在这篇文章中放了一些信息:Run (synchronize) mina client on Android, how to resolve ClassNotFoundException