[rules-users] OptionalDataException reading compiled Packages

Manish Shah gaiamech at gmail.com
Fri Aug 27 12:02:54 EDT 2010


Not sure what happened with this post yesterday, another chain got started
with it, so trying again.

I have the application setup where the drl is generated from the database
and then written to the file system. So far i have been working with the
drl's without any problems but have run into issues while working with
packages.

Any help is much appreciated. Thanks.

Here is what i am doing while serializing the package.

PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl(new StringReader(drl));
Package pkg = builder.getPackage();
DroolsStreamUtils.streamOut(new ObjectOutputStream(new FileOutputStream(new
File(fileName+".pkg"))), pkg);

i also tried the writeExternal on package, this genereate the file but got a
class cast exception while trying to load it.

The pkg file is generated and i dont think it has a problem unless i am
missing something in the above code.

Now, on the other side i am using drools-spring which sets up the agent on
startup. I was doing some trial and error and found two configurations that
worked but needed
                ResourceFactory.getResourceChangeScannerService().start();
                ResourceFactory.getResourceChangeNotifierService().start();

to be in code, just the spring configuration didnt work (again if i am
missing something please let me know).

here are the spring configuration
First
        <drools:kagent id="agent" kbase="base" new-instance="true"/>
        <drools:kbase id="base">
                <drools:resources>
                        <!--drools:resource type="DRL"
source="file:C:\file.drl"/--> //this works
                        <drools:resource type="PKG"
source="file:C:\file.pkg"/>
                </drools:resources>
        </drools:kbase-->

Second
        <drools:kagent id="agent" kbase="base" new-instance="true">
                <drools:resources>
                        <drools:resource type="CHANGE_SET"
source="file:C:\change-set.xml"/>
                </drools:resources>
        </drools:kagent>
        <drools:kbase id="base"></drools:kbase>

and the changeset
<change-set...>
       
   <add>
       <resource source='file:/C:/file.pkg' type='PKG'/>
   </add>
 </change-set> 
-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/OptionalDataException-reading-compiled-Packages-tp1374199p1374199.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list