Why don't you use DroolsObjectInputStream to deserialize it? Check the
integration tests on how to do it.
[]s
Edson
2007/12/6, Manan Gosalia <goldenmask13(a)yahoo.com>:
Hello,
I am trying to deserialize rule package from disk. However, I am getting
the following exception. I have also included the code that I use to
deserialize rule packages. I found only one link on the web that describes
this issue after looking around:
http://www.mail-archive.com/user@drools.codehaus.org/msg01731.html. But
there was no solution or help there. Any idea?
I am using drools 3.0.5 and Java 1.5.
Caused by: java.lang.ClassNotFoundException: [Lorg.drools.rule.Declaration
;
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at
java.net <
http://java.net.urlclassloader.fi/>.URLClassLoader.findClass(Unknown
Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.drools.rule.PackageCompilationData$PackageClassLoader.loadClass(Unknown
Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.drools.common.ObjectInputStreamWithLoader.resolveClass(Unknown
Source)
at java.io
<
http://java.io.objectinputstream.re/>.ObjectInputStream.readNonProxyDe...
Source)
at java.io
<
http://java.io.objectinputstream.re/>.ObjectInputStream.readClassDesc(...
Source)
at java.io
<
http://java.io.objectinputstream.re/>.ObjectInputStream.readArray(Unknown
Source)
at java.io
<
http://java.io.objectinputstream.re/>.ObjectInputStream.readObject0(Un...
Source)
at java.io
<
http://java.io.objectinputstream.de/>.ObjectInputStream.defaultReadFie...
Source)
at java.io
<
http://java.io.objectinputstream.re/>.ObjectInputStream.readSerialData...
Source)
at java.io
<
http://java.io.objectinputstream.re/>.ObjectInputStream.readOrdinaryOb...
Source)
at java.io
<
http://java.io.objectinputstream.re/>.ObjectInputStream.readObject0(Un...
Source)
at java.io
<
http://java.io.objectinputstream.re/>.ObjectInputStream.readObject(Unk...
Source)
at java.util.HashMap.readObject(Unknown Source)
at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io
<
http://java.io.objectstreamclass.in/>.ObjectStreamClass.invokeReadObje...
Source)
at java.io
<
http://java.io.objectinputstream.re/>.ObjectInputStream.readSerialData...
Source)
at java.io
<
http://java.io.objectinputstream.re/>.ObjectInputStream.readOrdinaryOb...
Source)
at java.io
<
http://java.io.objectinputstream.re/>.ObjectInputStream.readObject0(Un...
Source)
at java.io
<
http://java.io.objectinputstream.re/>.ObjectInputStream.readObject(Unk...
Source)
at org.drools.rule.PackageCompilationData.readExternal(Unknown Source)
at java.io
<
http://java.io.objectinputstream.re/>.ObjectInputStream.readExternalDa...
Source)
at java.io
<
http://java.io.objectinputstream.re/>.ObjectInputStream.readOrdinaryOb...
Source)
at java.io
<
http://java.io.objectinputstream.re/>.ObjectInputStream.readObject0(Un...
Source)
at java.io
<
http://java.io.objectinputstream.re/>.ObjectInputStream.readObject(Unk...
Source)
at org.drools.rule.Package.readExternal(Unknown Source)
at com.cisco.cp.engine.util.CPRuleUtil$CPRuleFileHelper.getRulePackage(
CPRuleUtil.java:654)
... 26 more
private Package getRulePackage(File file) throws Exception {
// Make sure file is a valid rule file with the proper rule file
// ... type.
if(file == null) {
throw new Exception("File argument is null");
}
if(!file.exists()) {
throw new Exception("File does not exist");
}
FileInputStream ruleFileInputStream = null;
ObjectInputStream ruleObjectInputStream = null;
Reader ruleFileReader = null;
Package rulePackage = null;
try {
rulePackage = new Package();
// If the rule file is already compiled, then we just have
// ... read it through object input stream.
ruleFileInputStream = new FileInputStream(file);
ruleObjectInputStream =
new ObjectInputStream(ruleFileInputStream);
rulePackage.readExternal(ruleObjectInputStream);
// Validate the package - this will throw exception if there
// ... were any error in the package.
rulePackage.checkValidity();
}
finally {
if (rulePackage != null &&
rulePackage.getErrorSummary() != null &&
!rulePackage.getErrorSummary().equals("")) {
System.out.println("RULE FILE ERRORS: " +
rulePackage.getErrorSummary());
}
if (ruleObjectInputStream != null) {
ruleObjectInputStream.close();
}
if (ruleFileInputStream != null) {
ruleFileInputStream.close();
}
if (ruleFileReader != null) {
ruleFileReader.close();
}
}
return rulePackage;
}
------------------------------
Looking for last minute shopping deals? Find them fast with Yahoo!
Search.<http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.co...
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @