Hello,
in our Java application we use several Jess engines and shadow facts. When
copying an engine with bsave and bload we sometimes get a curios problem. We
have shadow facts TimePoint:
public class TimePoint
implements Serializable, Logging
{
private transient PropertyChangeSupport pcs;
private ArrayList<PropertyChangeListener> pcls;
private String name;
private long tMin;
private long tMax;
private boolean integrated;
.
public TimePoint()
{
...
pcls = new ArrayList<PropertyChangeListener>();
pcs = new PropertyChangeSupport(this);
};
public void settMin (long tMin)
{
Long temp = this.tMin;
this.tMin = tMin;
pcs.firePropertyChange("tMin", new Long(temp), new
Long(tMin));
}
...
public void addPropertyChangeListener(PropertyChangeListener pcl)
{
pcls.add(pcl);
pcs.addPropertyChangeListener(pcl);
}
public void removePropertyChangeListener(PropertyChangeListener pcl)
{
pcls.remove(pcl);
pcs.removePropertyChangeListener(pcl);
}
private void readObject(ObjectInputStream in) throws
IOException, ClassNotFoundException
{
in.defaultReadObject();
pcs = new PropertyChangeSupport(this);
for (PropertyChangeListener pcl: pcls)
{
pcs.addPropertyChangeListener(pcl);
}
}
}
After trying several versions, we thought that this is the right solution.
When copying an engine with bsave and bload, the readObject() function
should register the listeners again. We also create a new
PropertyChangeSupport and declare it as transient (if we do not create a new
PropertyChangeSupport we get the same error as listed below).
Now, after a while, when several copyings are done, we modify a timePoint
fact - which exists in every engine - via rete.modify(.) in the first 7
engines everything works fine, but in engine 8 we get the following error:
----------------------------------------------------------------------------
Jess reported an error in routine modify.
Message: Error setting slot value.
at jess.FactList.modifyDefinstancedObject(FactList.java:396)
at jess.FactList.modify(FactList.java:287)
at jess.Rete.modify(Rete.java:673)
at jess.Rete.modify(Rete.java:654)
at jess.Rete.modify(Rete.java:620)
at main.Engines.modifyFact(Engines.java:219)
at main.Control.modifyFact(Control.java:381)
at
coFriend.dataPreprocessing.DataProcessThread.process(DataProcessThread.java:
222)
at
coFriend.dataPreprocessing.DataProcessThread.run(DataProcessThread.java:85)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at jess.SerializablePD.setPropertyValue(SerializablePD.java:58)
at jess.FactList.modifyDefinstancedObject(FactList.java:392)
... 8 more
Caused by: java.lang.NullPointerException
at jess.DefinstanceList.propertyChange(DefinstanceList.java:350)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown
Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown
Source)
at constraints.TimePoint.settMin(TimePoint.java:110)
... 13 more
Exception in thread "Thread-6" java.lang.RuntimeException: Error setting
slot value
at main.Main.showErrorMessage(Main.java:303)
at coFriend.main.CFMain.showErrorMessage(CFMain.java:348)
at
coFriend.dataPreprocessing.DataProcessThread.process(DataProcessThread.java:
256)
at
coFriend.dataPreprocessing.DataProcessThread.run(DataProcessThread.java:85)
------------------------------------------------------------------
Is it normal that a shadow fact has more than 1 listener? I printed out the
number of listeners, some timePoints have up to 6.
Does someone has an idea whats going wrong?
Thank you very much!
Wilfried Bohlken
Universtity Hamburg
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [email protected]'
in the BODY of a message to [email protected], NOT to the list
(use your own address!) List problems? Notify [email protected].
--------------------------------------------------------------------