It looks legit to me code-wise (I have some almost identical code, which works just
fine).
Are you using the same version of Drools in your project as the Guvnor you downloaded the
package from?
Steve
On 22 May 2013, at 10:19, abhinay_agarwal <abhinay_agarwal(a)infosys.com> wrote:
Hey,
I was trying to read a package(ResourceType.PKG), which i downloaded from
Guvnor, using KnowledgeBuilder, but I consistently get the following error
while trying to access the file.
Here's my code and the error,
**Code**
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource( "Goal Creation
Charges.pkg", getClass() ), ResourceType.PKG );
if ( kbuilder.hasErrors() ) {
System.err.println( kbuilder.getErrors().toString() );
}
kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
**Error**
java.lang.RuntimeException: java.io.StreamCorruptedException: invalid stream
header: 7061636B
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:724)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:51)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:40)
at
com.infosys.fps.drools.adapter.DroolsAdapter.readKnowledgeBase(DroolsAdapter.java:80)
at com.infosys.fps.drools.adapter.DroolsAdapter.main(DroolsAdapter.java:20)
Caused by: java.io.StreamCorruptedException: invalid stream header: 7061636B
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:783)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
at
org.drools.common.DroolsObjectInputStream.<init>(DroolsObjectInputStream.java:68)
at
org.drools.core.util.DroolsStreamUtils.streamIn(DroolsStreamUtils.java:205)
at
org.drools.core.util.DroolsStreamUtils.streamIn(DroolsStreamUtils.java:189)
at
org.drools.compiler.PackageBuilder.addPackageFromInputStream(PackageBuilder.java:819)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:711)
... 4 more
I have tried using both binary and source from guvnor, but neither of them
works. I get the same error. Is there something m doing wrong ?
Thanks,
Abhinay
--
View this message in context:
http://drools.46999.n3.nabble.com/Reading-a-Guvnor-PKG-from-drools-API-tp...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users