Java “StreamCorruptedException: invalid stream header”的可能原因

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3837574/
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-08-14 05:39:21  来源:igfitidea点击:

Possible causes for "StreamCorruptedException: invalid stream header"

javadrools

提问by Arne Deutsch

I (try to) use drools to process my pricing rules. But when I try to execute the rules the following exception is thrown:

我(尝试)使用流口水来处理我的定价规则。但是当我尝试执行规则时会抛出以下异常:

java.lang.RuntimeException: KnowledgeAgent exception while trying to deserialize KnowledgeDefinitionsPackage  
     at org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:418)
     at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:120)
     at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:109)
     at com.sapienter.jbilling.server.pluggableTask.PluggableTask.readKnowledgeBase(PluggableTask.java:115)
     at com.sapienter.jbilling.server.rule.RulesBaseTask.executeRules(RulesBaseTask.java:57)
     at com.sapienter.jbilling.server.item.tasks.RulesPricingTask2.getPrice(RulesPricingTask2.java:81)
     at com.sapienter.jbilling.server.item.ItemBL.getPrice(ItemBL.java:357)
[...many not so interesting lines...]
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
     at java.lang.Thread.run(Thread.java:619)
 Caused by: java.io.StreamCorruptedException: invalid stream header: 3C3F786D
     at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:783)
     at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
     at org.drools.common.DroolsObjectInputStream.<init>(DroolsObjectInputStream.java:55)
     at org.drools.common.DroolsObjectInputStream.<init>(DroolsObjectInputStream.java:49)
     at org.drools.util.DroolsStreamUtils.streamIn(DroolsStreamUtils.java:189)
     at org.drools.util.DroolsStreamUtils.streamIn(DroolsStreamUtils.java:158)
     at org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:408)
     ... 88 more

As all the code is from a library I guess the problem is not in the code but in my project setup/use of jars/use of rules/whatever. What are the typical reasons for this exception? What should I looking for to find the reason for the exception? Someone has a strategy to pinpoint the problem?

由于所有代码都来自库,我想问题不在于代码,而在于我的项目设置/使用 jars/使用规则/任何。这种异常的典型原因是什么?我应该寻找什么来找到异常的原因?有人有找出问题的策略吗?

Update:Interesting ... my application seems to work anyway. Looks like it recovers from the error. So, maybe a bug in the library of my project? Not nice to see the error logged at every startup, but don't seem to be critical. Hmmm ...

更新:有趣......我的应用程序似乎无论如何都可以工作。看起来它从错误中恢复了。那么,也许是我项目库中的一个错误?看到每次启动时记录的错误并不好,但似乎并不重要。嗯...

采纳答案by finereport

You are passing an XML file as an ObjectInputStream, but this data should be previously serialized via an ObjectOutputStream.

你是传递一个XML文件作为ObjectInputStream,但这一数据应通过一个预先序列化ObjectOutputStream