[rules-users] how to run pkg from java

Wolfgang Laun wolfgang.laun at gmail.com
Thu Apr 21 17:26:12 EDT 2011


I'm not sure how this .pkg file was created, but if I guess correctly,
you should be able
to add it to a KnowledgeBuilder:

   kbuilder.add( ResourceFactory.newFileResource( "...pkg" ),
ResourceType.PKG );

-W



On 21 April 2011 20:52, MichaelBini <michael at jspeed.co.il> wrote:
> Hi ,
> I Build  few classes using Eclipse and then import it into "JBoss BRMS"
> then I created few rule and and using "knowledge base" I created binary
> package.
> I try to open the pkg using Eclipse with this code :
>
>                Collection<KnowledgePackage> kpkgs = new ArrayList<KnowledgePackage>();
>
>                ObjectInputStream in = new ObjectInputStream(new FileInputStream(
>                                "c:/com.jspeed.brms.fire.pkg"));
>                Object o = in.readObject();
>                System.out.println("Read: pkg ok ");
>                in.close();
>                KnowledgePackage kp = (KnowledgePackage) o;
>                kpkgs.add(kp);
>
>                KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
>                kbase.addKnowledgePackages(kpkgs);
>
> and I am getting error -
> java.io.ObjectInputStream cannot be cast to
> org.drools.common.DroolsObjectInput
>
> What am I doing wrong ?
>
> My imports :
>
> import java.io.FileInputStream;
> import java.io.ObjectInputStream;
> import java.util.ArrayList;
> import java.util.Collection;
> import java.util.HashMap;
> import java.util.Map;
>
> import org.drools.KnowledgeBase;
> import org.drools.KnowledgeBaseFactory;
> import org.drools.definition.KnowledgePackage;
> import org.drools.runtime.StatefulKnowledgeSession;
> import org.drools.runtime.rule.FactHandle;
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/how-to-run-pkg-from-java-tp2848164p2848164.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>




More information about the rules-users mailing list