Hi Rajesh, 

You can use the org.drools.util.BinaryRuleBaseLoader to load a precompiled binary package into your classes.

    public void testLoadAndExecBinary() throws Exception {
        Person p = new Person();
        BinaryRuleBaseLoader loader = new BinaryRuleBaseLoader();
        loader.addPackage( this.getClass().getResourceAsStream( "/RepoBinPackage.pkg" ) );
        RuleBase rb = loader.getRuleBase();
        StatelessSession sess = rb.newStatelessSession();
        sess.execute( p );
        assertEquals(42, p.getAge());
    }

ps: next time use the Rules Users maillist rules-users@lists.jboss.org

Fernando Meyer
fmcamargo@gmail.com
GPG: 5A6D 3374 B055 A513 9A02  A03B 3DB3 7485 D804 DDFB


On Jun 1, 2007, at 3:20 AM, Rajesh_Kumar wrote:


hi ,

First of all congratulations to you for JBRMS release.

You and your team has done a great job.


I am facing some issue , when I use jbrms.

I have written a sample technical rule by following all the steps as mentioned in the document.

I am able to download binary package also,but when I tried to use this package in my rule engine class using following code it’s giving some error like …


 FileInputStream fis = new FileInputStream( "C:/drools/TestPackage.pkg" );

 ObjectInputStream ois = new ObjectInputStream( fis );

 Object objPackage = ois.readObject() ;

 

 when  ObjectInputStream object tries to read the object , its giving some  an error

  ois.close();

  fis.close();

Could you please help me out for this …

java.io.InvalidClassException: org.drools.rule.Rule; incompatible types for field salience

        at java.io.ObjectStreamClass.matchFields(Unknown Source)

        at java.io.ObjectStreamClass.getReflector(Unknown Source)

        at java.io.ObjectStreamClass.initNonProxy(Unknown Source)

        at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)

        at java.io.ObjectInputStream.readClassDesc(Unknown Source)

        at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)

        at java.io.ObjectInputStream.readObject0(Unknown Source)

        at java.io.ObjectInputStream.readObject(Unknown Source)

        at java.util.HashMap.readObject(Unknown Source)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

        at java.lang.reflect.Method.invoke(Unknown Source)

        at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)

        at java.io.ObjectInputStream.readSerialData(Unknown Source)

        at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)

        at java.io.ObjectInputStream.readObject0(Unknown Source)

        at java.io.ObjectInputStream.readObject(Unknown Source)

        at org.drools.rule.PackageCompilationData.readExternal(PackageCompilationData.java:128)

        at java.io.ObjectInputStream.readExternalData(Unknown Source)

        at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)

        at java.io.ObjectInputStream.readObject0(Unknown Source)

        at java.io.ObjectInputStream.readObject(Unknown Source)

        at org.drools.rule.Package.readExternal(Package.java:160)

        at java.io.ObjectInputStream.readExternalData(Unknown Source)

        at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)

        at java.io.ObjectInputStream.readObject0(Unknown Source)

        at java.io.ObjectInputStream.readObject(Unknown Source)

        at com.sample.DroolsTest.readRule(DroolsTest.java:36)

        at com.sample.DroolsTest.main(DroolsTest.java:17)