mina对象传输接收异常java.io.StreamCorruptedException: invalid type code: 00

   前几天将mina集成到j2ee项目中,然后在linux主机上的weblogic 11g部署。

   在测试中抛出如下异常:

 

org.apache.mina.filter.codec.ProtocolDecoderException: org.apache.mina.core.buffer.BufferDataException: java.io.StreamCorruptedException: invalid type code: 00 (Hexdump: 00 00 00 66 AC ED 00 05 73 72 01 00 11 6A 61 76 61 2E 75 74 69 6C 2E 48 61 73 68 4D 61 70 78 70 FF FF FF FF 3F 40 00 00 00 00 00 0C 77 08 00 00 00 10 00 00 00 03 74 00 05 6A 6F 62 49 64 74 00 02 31 31 74 00 07 63 6D 64 54 79 70 65 74 00 04 65 78 65 63 74 00 0A 74 61 73 6B 49 6E 73 74 49 64 74 00 05 35 35 34 32 37 78)
        at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:251)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)
        at org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:75)
        at org.apache.mina.core.session.IoEvent.run(IoEvent.java:63)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)
Caused by: org.apache.mina.core.buffer.BufferDataException: java.io.StreamCorruptedException: invalid type code: 00
        at org.apache.mina.core.buffer.AbstractIoBuffer.getObject(AbstractIoBuffer.java:2217)
        at org.apache.mina.filter.codec.serialization.ObjectSerializationDecoder.doDecode(ObjectSerializationDecoder.java:92)
        at org.apache.mina.filter.codec.CumulativeProtocolDecoder.decode(CumulativeProtocolDecoder.java:178)
        at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:241)
        ... 8 more

    其中,mina版本为2.0.4,客户端和服务端编码器都是使用ProtocolCodecFilter(new ObjectSerializationCodecFactory()),传输对象为hashmap,在自己本机上测试可以,但移植到weblogic上后就报上述异常。

    经过大半天的排查,终于定位到是jdk的问题。在我本机上的jdk是sun的1.6版本,而服务器上weblogic的jdk却是bea版本的。将weblogic的jdk更改为sun的1.6就可以了。

你可能感兴趣的:(Java,Mina)