[rules-users] OptionalDataException on reading packages..

mechlife gaiamech at gmail.com
Thu Aug 26 18:55:49 EDT 2010


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-on-reading-packages-tp1362967p1362967.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list