异常:java.io.StreamCorruptedException:无效类型代码:00

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2234406/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 20:11:57  来源:igfitidea点击:

Exception: java.io.StreamCorruptedException: invalid type code: 00

javaswingio

提问by Aaron

When I query through the EJB interface for a entity, under the console it is ok, but switch to query from Swing it throw this exception.

当我通过 EJB 接口查询实体时,在控制台下是可以的,但是从 Swing 切换到查询会抛出此异常。

The exception:

例外:

java.rmi.UnmarshalException: failed to unmarshal MY_ENTITY****; nested exception is: 
    java.io.StreamCorruptedException: invalid type code: 00
    at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:219)
    at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:224)
    at ***.****_6ndxy4_EOImpl_922_WLStub.getProductInformation(Unknown Source)
    at MY_CLASS****.getProductInformation(*****.java:460)
    at ******.run(OrigBlotter.java:318)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.io.StreamCorruptedException: invalid type code: 00
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1356)
    at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1642)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:195)
    at weblogic.rjvm.MsgAbbrevInputStream.readObject(MsgAbbrevInputStream.java:565)
    at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:191)
    at weblogic.rmi.internal.ObjectIO.readObject(ObjectIO.java:62)
    at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:217)

回答by Aaron

It turns out it is a JRE bug. As my console env is 1.5 and swing is 1.6:

事实证明这是一个 JRE 错误。因为我的控制台环境是 1.5,而摆动是 1.6:

Bug reference:

错误参考:

We need to pass this argument to the JVM

我们需要将此参数传递给 JVM

-Dsun.lang.ClassLoader.allowArraySyntax=true

-Dsun.lang.ClassLoader.allowArraySyntax=true

回答by drevicko

This exception is generated when the the class corresponding to the serialized object that is found by the JVM has the same serialVersionUid as the serialised class, but is actually a different version (ie: changes were made to the class without changing the version id).

当JVM找到的序列化对象对应的类与序列化类具有相同的serialVersionUid,但实际上是不同的版本(即:对类进行了更改而不更改版本id)时,会产生此异常。

Check that you have the relevant jar's/class files in the class path?

检查类路径中是否有相关的 jar/class 文件?