Hello,

we have found the reason for our problem. We used to assert the SAME new
shadow object as fact in all active engines, but it should be a copy of this
new fact for every engine. The problem is gone now.

Thanks,
Wilfried




-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] Im
Auftrag von Ernest Friedman-Hill
Gesendet: Donnerstag, 4. März 2010 16:29
An: jess-users
Betreff: Re: JESS: Problems with copying shadow facts via bsave and bload

Looking at the source, the only thing I can come up with is that maybe  
a change event is coming in during a bload call, so that the engine is  
not fully baked at the time. Is this possible?


On Mar 4, 2010, at 7:56 AM, bohlken wrote:

>
> 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] 
> .
> --------------------------------------------------------------------

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences          Phone: (925) 294-2154
Sandia National Labs
PO Box 969, MS 9012                            [email protected]
Livermore, CA 94550                             http://www.jessrules.com





--------------------------------------------------------------------
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].
--------------------------------------------------------------------



--------------------------------------------------------------------
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].
--------------------------------------------------------------------

Reply via email to