Android:Mina Client ClassNotFoundException

时间:2012-04-13 02:52:28

标签: android serialization classpath deserialization classnotfoundexception

我遇到了一个问题,当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

1 个答案:

答案 0 :(得分:0)

我认为在Message.jar中,您尝试访问的类“”egisterResponse“扩展了活动,在这种情况下,您必须在展示文件中添加这些活动。如下所示

<activity android:name="com.geoxy.message.agent.user.RegisterResponse" />

还要记住,如果我们的任何外部jar都有扩展Activity的classess,那么该活动也必须在我们的表现文件中声明。

尝试这可能会对您有所帮助。

或者尝试将jar文件放在项目的libs文件夹中,然后将其链接起来并尝试。