[
https://jira.jboss.org/browse/JBRULES-1925?page=com.atlassian.jira.plugin...
]
Mark Proctor updated JBRULES-1925:
----------------------------------
Fix Version/s: 5.2.0.M1
(was: 4.0.8)
These issues where all marked for 4.0.8, we no longer maintain the 4.0.x branch in the
community. I'm moving them to 5.2.0.M2, so they can be checked that they no longer
cause a problem there, and fixed if they do. If you require these fixed at the 4.0.x
branch level, then please contact sales(a)jboss.com for subscription based support.
ClassCastException problem with reading working memory using
ObjectInputStream
------------------------------------------------------------------------------
Key: JBRULES-1925
URL:
https://jira.jboss.org/browse/JBRULES-1925
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Affects Versions: 4.0.7
Environment: JDK 1.5.0_11
Reporter: Przemyslaw Rozycki
Assignee: Mark Proctor
Fix For: 5.2.0.M1
Attachments: DroolsTest5.java
I experienced the problem while reading WorkingMemory using ObjectInputStream.
Here is the code:
public class DroolsTest5 {
public static void main(String[] args) {
Properties props = new Properties();
props.setProperty("file", "<<place a path to any working DRL
here>>");
RuleAgent ruleAgent = RuleAgent.newRuleAgent(props);
Fact fact1 = new Fact("a","b");
RuleBase ruleBase = ruleAgent.getRuleBase();
WorkingMemory baseWm = ruleBase.newStatefulSession(false);
baseWm.insert(fact1);
Iterator iter1 = baseWm.iterateObjects();
while (iter1.hasNext()) {
System.out.println(iter1.next());
}
System.out.println("=====");
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(baseWm);
oos.close();
byte[] buf = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(buf);
ObjectInputStream ois = new ObjectInputStream(bais);
WorkingMemory wm = (WorkingMemory) ois.readObject();
Iterator iter2 = wm.iterateObjects();
while (iter2.hasNext()) {
System.out.println(iter2.next());
}
System.out.println("=====");
} catch (Exception e) {
e.printStackTrace();
}
}
public static class Fact implements Serializable {
String name;
String id;
public Fact(String _name, String _id) {
name = _name;
id = _id;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
@Override
public String toString() {
return "Name: " + name + ", Id: " + id;
}
}
}
And here is an exception I get:
java.lang.ClassCastException: java.io.ObjectInputStream
at org.drools.reteoo.Rete$ClassObjectTypeConf.readObject(Rete.java:605)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:946)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1809)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1634)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
at org.drools.util.AbstractHashTable.readExternal(AbstractHashTable.java:66)
at org.drools.util.ObjectHashMap.readExternal(ObjectHashMap.java:41)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1755)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1717)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1634)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1634)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
at com.sample.DroolsTest5.main(DroolsTest5.java:52)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira