JESS: how to store and fetch between java & jess

View: New views
11 Messages — Rating Filter:   Alert me  

JESS: how to store and fetch between java & jess

by Weijing Bai :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi, everyone
 
I have a problem .
 
It works well when  store a param in jess and fetch it in java, but it reports a error when store in java and fetch it in jess. the error is :" cannot find m" and so on.
 
who has once use "store-fetch " sucessfully, please give me some suggestions.
 
Is there any other way can pass a value from java to jess?
 
thank very much.
 
 
Esther Bai

Re: JESS: how to store and fetch between java & jess

by Ernest Friedman-Hill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think if you just show us the actual code that caused the error, and  
more details about the error -- i.e., is this a runtime or compile-
time error, from Java or from Jess, and include a stack trace -- I'm  
sure we can help you fix it. Please cut and paste the real code, and  
the real stack trace -- summaries and remembered bits and piece are  
normally not that helpful.

On Nov 5, 2009, at 1:29 AM, Weijing Bai wrote:

> hi, everyone
>
> I have a problem .
>
> It works well when  store a param in jess and fetch it in java, but  
> it reports a error when store in java and fetch it in jess. the  
> error is :" cannot find m" and so on.
>
> who has once use "store-fetch " sucessfully, please give me some  
> suggestions.
>
> Is there any other way can pass a value from java to jess?
>
> thank very much.
>
>
> Esther Bai

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, Livermore, CA 94550
http://www.jessrules.com







--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------


Re: JESS: how to store and fetch between java & jess

by Weijing Bai :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

oh,Thanks for your advice.


my java code:

  Rete engine = new Rete();
  engine.store("m", 7);
  engine.store("n", 5);

the jess clp:
" module2.txt"

(defglobal ?*m* = (fetch m ))
(defglobal ?*n* = (fetch n ))

(printout t"?m = " ?*m* crlf)
(printout t"?n = "  ?*n*  crlf)

(bind ?I (div ?*m* 2 ))
(bind ?J (+ ?*m*  ?*n* 2 ))
(bind ?J'(+ (div  (+ ?*m*  1) 2) 1))
(bind ?K (+ ?*m*   2 ))
(bind ?L (+ (div (- ?*m*  3) 2) 3))


the error message:

?m = nil
?n = nil
Exception in thread "main" Jess reported an error in routine Value.intValue
 while executing (div ?*m* 2)
 while executing (bind ?I (div ?*m* 2))
 while executing (batch D:Jess71p1\module2.txt)
  Message: 'nil' is a symbol, not  an integer.


what's more, I once want use this in my java code, it did not work also:
java code:

  Rete engine = new Rete();

 engine.eval("(defglobal ?*m* = 7)");
 engine.eval("(defglobal ?*n* = 5)");

"module2.txt":

(printout t"?m = " ?*m* crlf)
(printout t"?n = "  ?*n*  crlf)

reports error:
 while executing (printout t "?m = " ?*m* crlf)
 while executing (batch D:\module2.txt)
  Message: No such variable *m*.







On Thu, Nov 5, 2009 at 9:19 PM, Ernest Friedman-Hill <ejfried@...>wrote:

> I think if you just show us the actual code that caused the error, and more
> details about the error -- i.e., is this a runtime or compile-time error,
> from Java or from Jess, and include a stack trace -- I'm sure we can help
> you fix it. Please cut and paste the real code, and the real stack trace --
> summaries and remembered bits and piece are normally not that helpful.
>
>
> On Nov 5, 2009, at 1:29 AM, Weijing Bai wrote:
>
> hi, everyone
>>
>> I have a problem .
>>
>> It works well when  store a param in jess and fetch it in java, but it
>> reports a error when store in java and fetch it in jess. the error is :"
>> cannot find m" and so on.
>>
>> who has once use "store-fetch " sucessfully, please give me some
>> suggestions.
>>
>> Is there any other way can pass a value from java to jess?
>>
>> thank very much.
>>
>>
>> Esther Bai
>>
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences, Sandia National Laboratories
> PO Box 969, MS 9012, Livermore, CA 94550
> http://www.jessrules.com
>
>
>
>
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users you@...'
> in the BODY of a message to majordomo@..., NOT to the list
> (use your own address!) List problems? Notify owner-jess-users@...

Re: JESS: how to store and fetch between java & jess

by Ernest Friedman-Hill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You don't show the connection between the Java calls to "store()" and  
where Jess reads the module2.txt file. Are you sure it's the same  
instance of jess.Rete that's involved in both? In other words, where  
and how is "batch module2.txt" being invoked? Each Rete object will  
have its own independent storage map.

If it is the same Rete object, then perhaps there's a call to "clear"  
somewhere in between the store and fetch?



On Nov 5, 2009, at 8:47 AM, Weijing Bai wrote:

> oh,Thanks for your advice.
>
>
> my java code:
>
>  Rete engine = new Rete();
>  engine.store("m", 7);
>  engine.store("n", 5);
>
> the jess clp:
> " module2.txt"
>
> (defglobal ?*m* = (fetch m ))
> (defglobal ?*n* = (fetch n ))
>
> (printout t"?m = " ?*m* crlf)
> (printout t"?n = "  ?*n*  crlf)
>
> (bind ?I (div ?*m* 2 ))
> (bind ?J (+ ?*m*  ?*n* 2 ))
> (bind ?J'(+ (div  (+ ?*m*  1) 2) 1))
> (bind ?K (+ ?*m*   2 ))
> (bind ?L (+ (div (- ?*m*  3) 2) 3))
>
>
> the error message:
>
> ?m = nil
> ?n = nil
> Exception in thread "main" Jess reported an error in routine  
> Value.intValue
> while executing (div ?*m* 2)
> while executing (bind ?I (div ?*m* 2))
> while executing (batch D:Jess71p1\module2.txt)
>  Message: 'nil' is a symbol, not  an integer.
>
>
> what's more, I once want use this in my java code, it did not work  
> also:
> java code:
>
>  Rete engine = new Rete();
>
> engine.eval("(defglobal ?*m* = 7)");
> engine.eval("(defglobal ?*n* = 5)");
>
> "module2.txt":
>
> (printout t"?m = " ?*m* crlf)
> (printout t"?n = "  ?*n*  crlf)
>
> reports error:
> while executing (printout t "?m = " ?*m* crlf)
> while executing (batch D:\module2.txt)
>  Message: No such variable *m*.
>
>
>
>
>
>
>
> On Thu, Nov 5, 2009 at 9:19 PM, Ernest Friedman-Hill <ejfried@...
> >wrote:
>
>> I think if you just show us the actual code that caused the error,  
>> and more
>> details about the error -- i.e., is this a runtime or compile-time  
>> error,
>> from Java or from Jess, and include a stack trace -- I'm sure we  
>> can help
>> you fix it. Please cut and paste the real code, and the real stack  
>> trace --
>> summaries and remembered bits and piece are normally not that  
>> helpful.
>>
>>
>> On Nov 5, 2009, at 1:29 AM, Weijing Bai wrote:
>>
>> hi, everyone
>>>
>>> I have a problem .
>>>
>>> It works well when  store a param in jess and fetch it in java,  
>>> but it
>>> reports a error when store in java and fetch it in jess. the error  
>>> is :"
>>> cannot find m" and so on.
>>>
>>> who has once use "store-fetch " sucessfully, please give me some
>>> suggestions.
>>>
>>> Is there any other way can pass a value from java to jess?
>>>
>>> thank very much.
>>>
>>>
>>> Esther Bai
>>>
>>
>> ---------------------------------------------------------
>> Ernest Friedman-Hill
>> Informatics & Decision Sciences, Sandia National Laboratories
>> PO Box 969, MS 9012, Livermore, CA 94550
>> http://www.jessrules.com
>>
>>
>>
>>
>>
>>
>>
>> --------------------------------------------------------------------
>> To unsubscribe, send the words 'unsubscribe jess-users you@...
>> '
>> in the BODY of a message to majordomo@..., NOT to the list
>> (use your own address!) List problems? Notify owner-jess-users@...

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





--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------


Re: JESS: how to store and fetch between java & jess

by Weijing Bai :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ernest Friedman-Hill:

Thanks very much,  there is a call to "clear " between the store and fetch.
the
 engine.eval("(defglobal ?*m* = 7)");
 engine.eval("(defglobal ?*n* = 5)");
  can work well now.

But the first situation can not work also, I donot know how to change a
Java-Object:java.lang.Integer to integer in a jess text.



now it's report error is :

?m = <Java-Object:java.lang.Integer>
?n = <Java-Object:java.lang.Integer>
Exception in thread "main" Jess reported an error in routine Value.intValue
 while executing (div ?*m* 2)
 while executing (bind ?I (div ?*m* 2))
 while executing (batch D:module2.txt)
  Message: '<Java-Object:java.lang.Integer>' is JAVA_OBJECT, not  an
integer.

thanks a lot!



On Thu, Nov 5, 2009 at 10:08 PM, Ernest Friedman-Hill <ejfried@...>wrote:

> You don't show the connection between the Java calls to "store()" and where
> Jess reads the module2.txt file. Are you sure it's the same instance of
> jess.Rete that's involved in both? In other words, where and how is "batch
> module2.txt" being invoked? Each Rete object will have its own independent
> storage map.
>
> If it is the same Rete object, then perhaps there's a call to "clear"
> somewhere in between the store and fetch?
>
>
>
>
> On Nov 5, 2009, at 8:47 AM, Weijing Bai wrote:
>
> oh,Thanks for your advice.
>>
>>
>> my java code:
>>
>>  Rete engine = new Rete();
>>  engine.store("m", 7);
>>  engine.store("n", 5);
>>
>> the jess clp:
>> " module2.txt"
>>
>> (defglobal ?*m* = (fetch m ))
>> (defglobal ?*n* = (fetch n ))
>>
>> (printout t"?m = " ?*m* crlf)
>> (printout t"?n = "  ?*n*  crlf)
>>
>> (bind ?I (div ?*m* 2 ))
>> (bind ?J (+ ?*m*  ?*n* 2 ))
>> (bind ?J'(+ (div  (+ ?*m*  1) 2) 1))
>> (bind ?K (+ ?*m*   2 ))
>> (bind ?L (+ (div (- ?*m*  3) 2) 3))
>>
>>
>> the error message:
>>
>> ?m = nil
>> ?n = nil
>> Exception in thread "main" Jess reported an error in routine
>> Value.intValue
>> while executing (div ?*m* 2)
>> while executing (bind ?I (div ?*m* 2))
>> while executing (batch D:Jess71p1\module2.txt)
>>  Message: 'nil' is a symbol, not  an integer.
>>
>>
>> what's more, I once want use this in my java code, it did not work also:
>> java code:
>>
>>  Rete engine = new Rete();
>>
>> engine.eval("(defglobal ?*m* = 7)");
>> engine.eval("(defglobal ?*n* = 5)");
>>
>> "module2.txt":
>>
>> (printout t"?m = " ?*m* crlf)
>> (printout t"?n = "  ?*n*  crlf)
>>
>> reports error:
>> while executing (printout t "?m = " ?*m* crlf)
>> while executing (batch D:\module2.txt)
>>  Message: No such variable *m*.
>>
>>
>>
>>
>>
>>
>>
>> On Thu, Nov 5, 2009 at 9:19 PM, Ernest Friedman-Hill <ejfried@...
>> >wrote:
>>
>> I think if you just show us the actual code that caused the error, and
>>> more
>>> details about the error -- i.e., is this a runtime or compile-time error,
>>> from Java or from Jess, and include a stack trace -- I'm sure we can help
>>> you fix it. Please cut and paste the real code, and the real stack trace
>>> --
>>> summaries and remembered bits and piece are normally not that helpful.
>>>
>>>
>>> On Nov 5, 2009, at 1:29 AM, Weijing Bai wrote:
>>>
>>> hi, everyone
>>>
>>>>
>>>> I have a problem .
>>>>
>>>> It works well when  store a param in jess and fetch it in java, but it
>>>> reports a error when store in java and fetch it in jess. the error is :"
>>>> cannot find m" and so on.
>>>>
>>>> who has once use "store-fetch " sucessfully, please give me some
>>>> suggestions.
>>>>
>>>> Is there any other way can pass a value from java to jess?
>>>>
>>>> thank very much.
>>>>
>>>>
>>>> Esther Bai
>>>>
>>>>
>>> ---------------------------------------------------------
>>> Ernest Friedman-Hill
>>> Informatics & Decision Sciences, Sandia National Laboratories
>>> PO Box 969, MS 9012, Livermore, CA 94550
>>> http://www.jessrules.com
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --------------------------------------------------------------------
>>> To unsubscribe, send the words 'unsubscribe jess-users you@...'
>>> in the BODY of a message to majordomo@..., NOT to the list
>>> (use your own address!) List problems? Notify
>>> owner-jess-users@...
>>>
>>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences          Phone: (925) 294-2154
> Sandia National Labs
> PO Box 969, MS 9012                            ejfried@...
>
> Livermore, CA 94550                             http://www.jessrules.com
>
>
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users you@...'
> in the BODY of a message to majordomo@..., NOT to the list
> (use your own address!) List problems? Notify owner-jess-users@...

Re: JESS: how to store and fetch between java & jess

by Wolfgang Laun-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What is stored under the keys "m" and "n" is a java.lang.Integer object. There's no problem with *fetching* this from Jess, but it's evaluation in a Jess expression - even after being stored in a defglobal or plain variable - is quite another matter.

I think looking at the Jess code below will show you what I mean. (jv = Jess Value, jo = Java Object)

(clear)

((engine) store jv (new jess.Value 7 4))
((engine) store jo (new Integer    7 ))

(bind ?value ((engine) fetch jv))
(printout t "value=" ?value crlf)
Jess> value=7

(bind ?value ((engine) fetch jo))
(printout t "value=" ?value crlf)
Jess> value=<Java-Object:java.lang.Integer>

(defglobal ?*m* = (fetch jv ))
(printout t "global ?*m*=" ?*m* crlf)
Jess> global ?*m*=7

(defglobal ?*n* = (fetch jo ))
(printout t "global ?*n*=" ?*n* crlf)
Jess> global ?*n*=<Java-Object:java.lang.Integer>

Cheers
-W


On Thu, Nov 5, 2009 at 2:47 PM, Weijing Bai <estherbaiweijing@...> wrote:
oh,Thanks for your advice.


my java code:

 Rete engine = new Rete();
 engine.store("m", 7);
 engine.store("n", 5);

the jess clp:
" module2.txt"

(defglobal ?*m* = (fetch m ))
(defglobal ?*n* = (fetch n ))

(printout t"?m = " ?*m* crlf)
(printout t"?n = "  ?*n*  crlf)

(bind ?I (div ?*m* 2 ))
(bind ?J (+ ?*m*  ?*n* 2 ))
(bind ?J'(+ (div  (+ ?*m*  1) 2) 1))
(bind ?K (+ ?*m*   2 ))
(bind ?L (+ (div (- ?*m*  3) 2) 3))


the error message:

?m = nil
?n = nil
Exception in thread "main" Jess reported an error in routine Value.intValue
 while executing (div ?*m* 2)
 while executing (bind ?I (div ?*m* 2))
 while executing (batch D:Jess71p1\module2.txt)
 Message: 'nil' is a symbol, not  an integer.


what's more, I once want use this in my java code, it did not work also:
java code:

 Rete engine = new Rete();

 engine.eval("(defglobal ?*m* = 7)");
 engine.eval("(defglobal ?*n* = 5)");

"module2.txt":

(printout t"?m = " ?*m* crlf)
(printout t"?n = "  ?*n*  crlf)

reports error:
 while executing (printout t "?m = " ?*m* crlf)
 while executing (batch D:\module2.txt)
 Message: No such variable *m*.







On Thu, Nov 5, 2009 at 9:19 PM, Ernest Friedman-Hill <ejfried@...>wrote:

> I think if you just show us the actual code that caused the error, and more
> details about the error -- i.e., is this a runtime or compile-time error,
> from Java or from Jess, and include a stack trace -- I'm sure we can help
> you fix it. Please cut and paste the real code, and the real stack trace --
> summaries and remembered bits and piece are normally not that helpful.
>
>
> On Nov 5, 2009, at 1:29 AM, Weijing Bai wrote:
>
> hi, everyone
>>
>> I have a problem .
>>
>> It works well when  store a param in jess and fetch it in java, but it
>> reports a error when store in java and fetch it in jess. the error is :"
>> cannot find m" and so on.
>>
>> who has once use "store-fetch " sucessfully, please give me some
>> suggestions.
>>
>> Is there any other way can pass a value from java to jess?
>>
>> thank very much.
>>
>>
>> Esther Bai
>>
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences, Sandia National Laboratories
> PO Box 969, MS 9012, Livermore, CA 94550
> http://www.jessrules.com
>
>
>
>
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users you@...'
> in the BODY of a message to majordomo@..., NOT to the list
> (use your own address!) List problems? Notify owner-jess-users@...


Re: JESS: how to store and fetch between java & jess

by Jason Morris :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey Ernest,

Assuming that Weijing resolves the Rete instance disconnect, won't he still
will have a problem because he's trying to compute with the fetched Integer
object and not its int value?  Here's how I massaged his code:

; a.clp
; ======
; Note: this file has parsing errors because it lacks a Rete object
reference.
; However, this script is called by the attached driver class, so it works.

(defglobal ?*m* = ((fetch m) intValue))
(defglobal ?*n* = ((fetch n) intValue))

(printout t"?m = " ?*m* crlf) ; checking m value
(printout t"?n = " ?*n* crlf) ; checking n value

(bind ?I (div ?*m* 2 ))(printout t "?I = " ?I crlf)
(bind ?J (+ ?*m*  ?*n* 2 ))(printout t "?J = " ?I crlf)
(bind ?J'(+ (div  (+ ?*m*  1) 2) 1))(printout t "?J' = " ?J' crlf)
(bind ?K (+ ?*m*   2 ))(printout t "?K = " ?K crlf)
(bind ?L (+ (div (- ?*m*  3) 2) 3))(printout t "?L = " ?L crlf)

then I wrote a simple driver to replace his missing code...

import jess.JessException;
import jess.Rete;

public class StoreProblemDriver {
    public static void main(String[] args) {
         Rete engine = new Rete();
         engine.store("m", 7);
         engine.store("n", 5);

         try {
            engine.batch("clp/a.clp");
        } catch (JessException e) {
            e.printStackTrace();
        }
    }
}

which produced the output...

; OUTPUT
;========
;?m = 7
;?n = 5
;?I = 3
;?J = 3
;?J' = 5
;?K = 9
;?L = 5

Weijing: Is this what you wanted?

Cheers,
Jason


On Thu, Nov 5, 2009 at 9:08 AM, Ernest Friedman-Hill <ejfried@...>wrote:

> You don't show the connection between the Java calls to "store()" and where
> Jess reads the module2.txt file. Are you sure it's the same instance of
> jess.Rete that's involved in both? In other words, where and how is "batch
> module2.txt" being invoked? Each Rete object will have its own independent
> storage map.
>
> If it is the same Rete object, then perhaps there's a call to "clear"
> somewhere in between the store and fetch?
>
>
>
>
> On Nov 5, 2009, at 8:47 AM, Weijing Bai wrote:
>
>  oh,Thanks for your advice.
>>
>>
>> my java code:
>>
>>  Rete engine = new Rete();
>>  engine.store("m", 7);
>>  engine.store("n", 5);
>>
>> the jess clp:
>> " module2.txt"
>>
>> (defglobal ?*m* = (fetch m ))
>> (defglobal ?*n* = (fetch n ))
>>
>> (printout t"?m = " ?*m* crlf)
>> (printout t"?n = "  ?*n*  crlf)
>>
>> (bind ?I (div ?*m* 2 ))
>> (bind ?J (+ ?*m*  ?*n* 2 ))
>> (bind ?J'(+ (div  (+ ?*m*  1) 2) 1))
>> (bind ?K (+ ?*m*   2 ))
>> (bind ?L (+ (div (- ?*m*  3) 2) 3))
>>
>>
>> the error message:
>>
>> ?m = nil
>> ?n = nil
>> Exception in thread "main" Jess reported an error in routine
>> Value.intValue
>> while executing (div ?*m* 2)
>> while executing (bind ?I (div ?*m* 2))
>> while executing (batch D:Jess71p1\module2.txt)
>>  Message: 'nil' is a symbol, not  an integer.
>>
>>
>> what's more, I once want use this in my java code, it did not work also:
>> java code:
>>
>>  Rete engine = new Rete();
>>
>> engine.eval("(defglobal ?*m* = 7)");
>> engine.eval("(defglobal ?*n* = 5)");
>>
>> "module2.txt":
>>
>> (printout t"?m = " ?*m* crlf)
>> (printout t"?n = "  ?*n*  crlf)
>>
>> reports error:
>> while executing (printout t "?m = " ?*m* crlf)
>> while executing (batch D:\module2.txt)
>>  Message: No such variable *m*.
>>
>>
>>
>>
>>
>>
>>
>> On Thu, Nov 5, 2009 at 9:19 PM, Ernest Friedman-Hill <ejfried@...
>> >wrote:
>>
>>  I think if you just show us the actual code that caused the error, and
>>> more
>>> details about the error -- i.e., is this a runtime or compile-time error,
>>> from Java or from Jess, and include a stack trace -- I'm sure we can help
>>> you fix it. Please cut and paste the real code, and the real stack trace
>>> --
>>> summaries and remembered bits and piece are normally not that helpful.
>>>
>>>
>>> On Nov 5, 2009, at 1:29 AM, Weijing Bai wrote:
>>>
>>> hi, everyone
>>>
>>>>
>>>> I have a problem .
>>>>
>>>> It works well when  store a param in jess and fetch it in java, but it
>>>> reports a error when store in java and fetch it in jess. the error is :"
>>>> cannot find m" and so on.
>>>>
>>>> who has once use "store-fetch " sucessfully, please give me some
>>>> suggestions.
>>>>
>>>> Is there any other way can pass a value from java to jess?
>>>>
>>>> thank very much.
>>>>
>>>>
>>>> Esther Bai
>>>>
>>>>
>>> ---------------------------------------------------------
>>> Ernest Friedman-Hill
>>> Informatics & Decision Sciences, Sandia National Laboratories
>>> PO Box 969, MS 9012, Livermore, CA 94550
>>> http://www.jessrules.com
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --------------------------------------------------------------------
>>> To unsubscribe, send the words 'unsubscribe jess-users you@...'
>>> in the BODY of a message to majordomo@..., NOT to the list
>>> (use your own address!) List problems? Notify
>>> owner-jess-users@...
>>>
>>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences          Phone: (925) 294-2154
> Sandia National Labs
> PO Box 969, MS 9012                            ejfried@...
>
> Livermore, CA 94550                             http://www.jessrules.com
>
>
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users you@...'
> in the BODY of a message to majordomo@..., NOT to the list
> (use your own address!) List problems? Notify owner-jess-users@...

Re: JESS: how to store and fetch between java & jess

by Jason Morris :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I should add that if I replace the code

(defglobal ?*m* = ((fetch m) intValue))
(defglobal ?*n* = ((fetch n) intValue))

with

(defglobal ?*m* = (fetch m))
(defglobal ?*n* = (fetch n))

as in Weijing's orginal code, I get

Jess reported an error in routine Value.intValue
    while executing (div ?*m* 2)
    while executing (bind ?I (div ?*m* 2)).
  Message: '<Java-Object:java.lang.Integer>' is JAVA_OBJECT, not  an
integer.
  Program text: ( bind ?I ( div ?*m* 2 ) )  at line 14 in file clp/a.clp.



On Thu, Nov 5, 2009 at 9:08 AM, Ernest Friedman-Hill <ejfried@...>wrote:

> You don't show the connection between the Java calls to "store()" and where
> Jess reads the module2.txt file. Are you sure it's the same instance of
> jess.Rete that's involved in both? In other words, where and how is "batch
> module2.txt" being invoked? Each Rete object will have its own independent
> storage map.
>
> If it is the same Rete object, then perhaps there's a call to "clear"
> somewhere in between the store and fetch?
>
>
>
>
> On Nov 5, 2009, at 8:47 AM, Weijing Bai wrote:
>
>  oh,Thanks for your advice.
>>
>>
>> my java code:
>>
>>  Rete engine = new Rete();
>>  engine.store("m", 7);
>>  engine.store("n", 5);
>>
>> the jess clp:
>> " module2.txt"
>>
>> (defglobal ?*m* = (fetch m ))
>> (defglobal ?*n* = (fetch n ))
>>
>> (printout t"?m = " ?*m* crlf)
>> (printout t"?n = "  ?*n*  crlf)
>>
>> (bind ?I (div ?*m* 2 ))
>> (bind ?J (+ ?*m*  ?*n* 2 ))
>> (bind ?J'(+ (div  (+ ?*m*  1) 2) 1))
>> (bind ?K (+ ?*m*   2 ))
>> (bind ?L (+ (div (- ?*m*  3) 2) 3))
>>
>>
>> the error message:
>>
>> ?m = nil
>> ?n = nil
>> Exception in thread "main" Jess reported an error in routine
>> Value.intValue
>> while executing (div ?*m* 2)
>> while executing (bind ?I (div ?*m* 2))
>> while executing (batch D:Jess71p1\module2.txt)
>>  Message: 'nil' is a symbol, not  an integer.
>>
>>
>> what's more, I once want use this in my java code, it did not work also:
>> java code:
>>
>>  Rete engine = new Rete();
>>
>> engine.eval("(defglobal ?*m* = 7)");
>> engine.eval("(defglobal ?*n* = 5)");
>>
>> "module2.txt":
>>
>> (printout t"?m = " ?*m* crlf)
>> (printout t"?n = "  ?*n*  crlf)
>>
>> reports error:
>> while executing (printout t "?m = " ?*m* crlf)
>> while executing (batch D:\module2.txt)
>>  Message: No such variable *m*.
>>
>>
>>
>>
>>
>>
>>
>> On Thu, Nov 5, 2009 at 9:19 PM, Ernest Friedman-Hill <ejfried@...
>> >wrote:
>>
>>  I think if you just show us the actual code that caused the error, and
>>> more
>>> details about the error -- i.e., is this a runtime or compile-time error,
>>> from Java or from Jess, and include a stack trace -- I'm sure we can help
>>> you fix it. Please cut and paste the real code, and the real stack trace
>>> --
>>> summaries and remembered bits and piece are normally not that helpful.
>>>
>>>
>>> On Nov 5, 2009, at 1:29 AM, Weijing Bai wrote:
>>>
>>> hi, everyone
>>>
>>>>
>>>> I have a problem .
>>>>
>>>> It works well when  store a param in jess and fetch it in java, but it
>>>> reports a error when store in java and fetch it in jess. the error is :"
>>>> cannot find m" and so on.
>>>>
>>>> who has once use "store-fetch " sucessfully, please give me some
>>>> suggestions.
>>>>
>>>> Is there any other way can pass a value from java to jess?
>>>>
>>>> thank very much.
>>>>
>>>>
>>>> Esther Bai
>>>>
>>>>
>>> ---------------------------------------------------------
>>> Ernest Friedman-Hill
>>> Informatics & Decision Sciences, Sandia National Laboratories
>>> PO Box 969, MS 9012, Livermore, CA 94550
>>> http://www.jessrules.com
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --------------------------------------------------------------------
>>> To unsubscribe, send the words 'unsubscribe jess-users you@...'
>>> in the BODY of a message to majordomo@..., NOT to the list
>>> (use your own address!) List problems? Notify
>>> owner-jess-users@...
>>>
>>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences          Phone: (925) 294-2154
> Sandia National Labs
> PO Box 969, MS 9012                            ejfried@...
>
> Livermore, CA 94550                             http://www.jessrules.com
>
>
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users you@...'
> in the BODY of a message to majordomo@..., NOT to the list
> (use your own address!) List problems? Notify owner-jess-users@...

Re: JESS: how to store and fetch between java & jess

by Weijing Bai :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OH,YES!

It works! That's really what I wanted. Thanks very much!


Thanks all you guys.





PS: I am "she", not "he". Haha!





On Thu, Nov 5, 2009 at 10:50 PM, Jason Morris <jason.c.morris@...>wrote:

> Hey Ernest,
>
> Assuming that Weijing resolves the Rete instance disconnect, won't he still
> will have a problem because he's trying to compute with the fetched Integer
> object and not its int value?  Here's how I massaged his code:
>
> ; a.clp
> ; ======
> ; Note: this file has parsing errors because it lacks a Rete object
> reference.
> ; However, this script is called by the attached driver class, so it works.
>
> (defglobal ?*m* = ((fetch m) intValue))
> (defglobal ?*n* = ((fetch n) intValue))
>
> (printout t"?m = " ?*m* crlf) ; checking m value
> (printout t"?n = " ?*n* crlf) ; checking n value
>
> (bind ?I (div ?*m* 2 ))(printout t "?I = " ?I crlf)
> (bind ?J (+ ?*m*  ?*n* 2 ))(printout t "?J = " ?I crlf)
> (bind ?J'(+ (div  (+ ?*m*  1) 2) 1))(printout t "?J' = " ?J' crlf)
> (bind ?K (+ ?*m*   2 ))(printout t "?K = " ?K crlf)
> (bind ?L (+ (div (- ?*m*  3) 2) 3))(printout t "?L = " ?L crlf)
>
> then I wrote a simple driver to replace his missing code...
>
> import jess.JessException;
> import jess.Rete;
>
> public class StoreProblemDriver {
>    public static void main(String[] args) {
>         Rete engine = new Rete();
>         engine.store("m", 7);
>         engine.store("n", 5);
>
>         try {
>            engine.batch("clp/a.clp");
>        } catch (JessException e) {
>            e.printStackTrace();
>        }
>    }
> }
>
> which produced the output...
>
> ; OUTPUT
> ;========
> ;?m = 7
> ;?n = 5
> ;?I = 3
> ;?J = 3
> ;?J' = 5
> ;?K = 9
> ;?L = 5
>
> Weijing: Is this what you wanted?
>
> Cheers,
> Jason
>
>
> On Thu, Nov 5, 2009 at 9:08 AM, Ernest Friedman-Hill <ejfried@...
> >wrote:
>
> > You don't show the connection between the Java calls to "store()" and
> where
> > Jess reads the module2.txt file. Are you sure it's the same instance of
> > jess.Rete that's involved in both? In other words, where and how is
> "batch
> > module2.txt" being invoked? Each Rete object will have its own
> independent
> > storage map.
> >
> > If it is the same Rete object, then perhaps there's a call to "clear"
> > somewhere in between the store and fetch?
> >
> >
> >
> >
> > On Nov 5, 2009, at 8:47 AM, Weijing Bai wrote:
> >
> >  oh,Thanks for your advice.
> >>
> >>
> >> my java code:
> >>
> >>  Rete engine = new Rete();
> >>  engine.store("m", 7);
> >>  engine.store("n", 5);
> >>
> >> the jess clp:
> >> " module2.txt"
> >>
> >> (defglobal ?*m* = (fetch m ))
> >> (defglobal ?*n* = (fetch n ))
> >>
> >> (printout t"?m = " ?*m* crlf)
> >> (printout t"?n = "  ?*n*  crlf)
> >>
> >> (bind ?I (div ?*m* 2 ))
> >> (bind ?J (+ ?*m*  ?*n* 2 ))
> >> (bind ?J'(+ (div  (+ ?*m*  1) 2) 1))
> >> (bind ?K (+ ?*m*   2 ))
> >> (bind ?L (+ (div (- ?*m*  3) 2) 3))
> >>
> >>
> >> the error message:
> >>
> >> ?m = nil
> >> ?n = nil
> >> Exception in thread "main" Jess reported an error in routine
> >> Value.intValue
> >> while executing (div ?*m* 2)
> >> while executing (bind ?I (div ?*m* 2))
> >> while executing (batch D:Jess71p1\module2.txt)
> >>  Message: 'nil' is a symbol, not  an integer.
> >>
> >>
> >> what's more, I once want use this in my java code, it did not work also:
> >> java code:
> >>
> >>  Rete engine = new Rete();
> >>
> >> engine.eval("(defglobal ?*m* = 7)");
> >> engine.eval("(defglobal ?*n* = 5)");
> >>
> >> "module2.txt":
> >>
> >> (printout t"?m = " ?*m* crlf)
> >> (printout t"?n = "  ?*n*  crlf)
> >>
> >> reports error:
> >> while executing (printout t "?m = " ?*m* crlf)
> >> while executing (batch D:\module2.txt)
> >>  Message: No such variable *m*.
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> On Thu, Nov 5, 2009 at 9:19 PM, Ernest Friedman-Hill <
> ejfried@...
> >> >wrote:
> >>
> >>  I think if you just show us the actual code that caused the error, and
> >>> more
> >>> details about the error -- i.e., is this a runtime or compile-time
> error,
> >>> from Java or from Jess, and include a stack trace -- I'm sure we can
> help
> >>> you fix it. Please cut and paste the real code, and the real stack
> trace
> >>> --
> >>> summaries and remembered bits and piece are normally not that helpful

Re: JESS: how to store and fetch between java & jess

by Jason Morris :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OH,YES!
It works! That's really what I wanted. Thanks very much!
Thanks all you guys.

You are very welcome :-)

PS: I am "she", not "he". Haha!
 
Arrggg!!  Much to my chagrin, Wolfgang admonished me for that... I'm terribly sorry! 
Cheers,
Jason

On Thu, Nov 5, 2009 at 10:19 AM, Weijing Bai <estherbaiweijing@...> wrote:
OH,YES!

It works! That's really what I wanted. Thanks very much!


Thanks all you guys.





PS: I am "she", not "he". Haha!





On Thu, Nov 5, 2009 at 10:50 PM, Jason Morris <jason.c.morris@...>wrote:

> Hey Ernest,
>
> Assuming that Weijing resolves the Rete instance disconnect, won't he still
> will have a problem because he's trying to compute with the fetched Integer
> object and not its int value?  Here's how I massaged his code:
>
> ; a.clp
> ; ======
> ; Note: this file has parsing errors because it lacks a Rete object
> reference.
> ; However, this script is called by the attached driver class, so it works.
>
> (defglobal ?*m* = ((fetch m) intValue))
> (defglobal ?*n* = ((fetch n) intValue))
>
> (printout t"?m = " ?*m* crlf) ; checking m value
> (printout t"?n = " ?*n* crlf) ; checking n value
>
> (bind ?I (div ?*m* 2 ))(printout t "?I = " ?I crlf)
> (bind ?J (+ ?*m*  ?*n* 2 ))(printout t "?J = " ?I crlf)
> (bind ?J'(+ (div  (+ ?*m*  1) 2) 1))(printout t "?J' = " ?J' crlf)
> (bind ?K (+ ?*m*   2 ))(printout t "?K = " ?K crlf)
> (bind ?L (+ (div (- ?*m*  3) 2) 3))(printout t "?L = " ?L crlf)
>
> then I wrote a simple driver to replace his missing code...
>
> import jess.JessException;
> import jess.Rete;
>
> public class StoreProblemDriver {
>    public static void main(String[] args) {
>         Rete engine = new Rete();
>         engine.store("m", 7);
>         engine.store("n", 5);
>
>         try {
>            engine.batch("clp/a.clp");
>        } catch (JessException e) {
>            e.printStackTrace();
>        }
>    }
> }
>
> which produced the output...
>
> ; OUTPUT
> ;========
> ;?m = 7
> ;?n = 5
> ;?I = 3
> ;?J = 3
> ;?J' = 5
> ;?K = 9
> ;?L = 5
>
> Weijing: Is this what you wanted?
>
> Cheers,
> Jason
>
>
> On Thu, Nov 5, 2009 at 9:08 AM, Ernest Friedman-Hill <ejfried@...
> >wrote:
>
> > You don't show the connection between the Java calls to "store()" and
> where
> > Jess reads the module2.txt file. Are you sure it's the same instance of
> > jess.Rete that's involved in both? In other words, where and how is
> "batch
> > module2.txt" being invoked? Each Rete object will have its own
> independent
> > storage map.
> >
> > If it is the same Rete object, then perhaps there's a call to "clear"
> > somewhere in between the store and fetch?
> >
> >
> >
> >
> > On Nov 5, 2009, at 8:47 AM, Weijing Bai wrote:
> >
> >  oh,Thanks for your advice.
> >>
> >>
> >> my java code:
> >>
> >>  Rete engine = new Rete();
> >>  engine.store("m", 7);
> >>  engine.store("n", 5);
> >>
> >> the jess clp:
> >> " module2.txt"
> >>
> >> (defglobal ?*m* = (fetch m ))
> >> (defglobal ?*n* = (fetch n ))
> >>
> >> (printout t"?m = " ?*m* crlf)
> >> (printout t"?n = "  ?*n*  crlf)
> >>
> >> (bind ?I (div ?*m* 2 ))
> >> (bind ?J (+ ?*m*  ?*n* 2 ))
> >> (bind ?J'(+ (div  (+ ?*m*  1) 2) 1))
> >> (bind ?K (+ ?*m*   2 ))
> >> (bind ?L (+ (div (- ?*m*  3) 2) 3))
> >>
> >>
> >> the error message:
> >>
> >> ?m = nil
> >> ?n = nil
> >> Exception in thread "main" Jess reported an error in routine
> >> Value.intValue
> >> while executing (div ?*m* 2)
> >> while executing (bind ?I (div ?*m* 2))
> >> while executing (batch D:Jess71p1\module2.txt)
> >>  Message: 'nil' is a symbol, not  an integer.
> >>
> >>
> >> what's more, I once want use this in my java code, it did not work also:
> >> java code:
> >>
> >>  Rete engine = new Rete();
> >>
> >> engine.eval("(defglobal ?*m* = 7)");
> >> engine.eval("(defglobal ?*n* = 5)");
> >>
> >> "module2.txt":
> >>
> >> (printout t"?m = " ?*m* crlf)
> >> (printout t"?n = "  ?*n*  crlf)
> >>
> >> reports error:
> >> while executing (printout t "?m = " ?*m* crlf)
> >> while executing (batch D:\module2.txt)
> >>  Message: No such variable *m*.
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> On Thu, Nov 5, 2009 at 9:19 PM, Ernest Friedman-Hill <
> ejfried@...
> >> >wrote:
> >>
> >>  I think if you just show us the actual code that caused the error, and
> >>> more
> >>> details about the error -- i.e., is this a runtime or compile-time
> error,
> >>> from Java or from Jess, and include a stack trace -- I'm sure we can
> help
> >>> you fix it. Please cut and paste the real code, and the real stack
> trace
> >>> --
> >>> summaries and remembered bits and piece are normally not that helpful



--
Cheers,
Jason
----------------------------------------------------------
Morris Technical Solutions LLC
consulting@...
(517) 304-5883

Re: JESS: how to store and fetch between java & jess

by Jason Morris :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OH,YES!
It works! That's really what I wanted. Thanks very much!
Thanks all you guys.

You are very welcome :-)

PS: I am "she", not "he". Haha!
 
Arrggg!!  Much to my chagrin, Wolfgang admonished me for that... I'm terribly sorry! 
Cheers,
Jason

On Thu, Nov 5, 2009 at 10:19 AM, Weijing Bai <estherbaiweijing@...> wrote:
OH,YES!

It works! That's really what I wanted. Thanks very much!


Thanks all you guys.





PS: I am "she", not "he". Haha!





On Thu, Nov 5, 2009 at 10:50 PM, Jason Morris <jason.c.morris@...>wrote:

> Hey Ernest,
>
> Assuming that Weijing resolves the Rete instance disconnect, won't he still
> will have a problem because he's trying to compute with the fetched Integer
> object and not its int value?  Here's how I massaged his code:
>
> ; a.clp
> ; ======
> ; Note: this file has parsing errors because it lacks a Rete object
> reference.
> ; However, this script is called by the attached driver class, so it works.
>
> (defglobal ?*m* = ((fetch m) intValue))
> (defglobal ?*n* = ((fetch n) intValue))
>
> (printout t"?m = " ?*m* crlf) ; checking m value
> (printout t"?n = " ?*n* crlf) ; checking n value
>
> (bind ?I (div ?*m* 2 ))(printout t "?I = " ?I crlf)
> (bind ?J (+ ?*m*  ?*n* 2 ))(printout t "?J = " ?I crlf)
> (bind ?J'(+ (div  (+ ?*m*  1) 2) 1))(printout t "?J' = " ?J' crlf)
> (bind ?K (+ ?*m*   2 ))(printout t "?K = " ?K crlf)
> (bind ?L (+ (div (- ?*m*  3) 2) 3))(printout t "?L = " ?L crlf)
>
> then I wrote a simple driver to replace his missing code...
>
> import jess.JessException;
> import jess.Rete;
>
> public class StoreProblemDriver {
>    public static void main(String[] args) {
>         Rete engine = new Rete();
>         engine.store("m", 7);
>         engine.store("n", 5);
>
>         try {
>            engine.batch("clp/a.clp");
>        } catch (JessException e) {
>            e.printStackTrace();
>        }
>    }
> }
>
> which produced the output...
>
> ; OUTPUT
> ;========
> ;?m = 7
> ;?n = 5
> ;?I = 3
> ;?J = 3
> ;?J' = 5
> ;?K = 9
> ;?L = 5
>
> Weijing: Is this what you wanted?
>
> Cheers,
> Jason
>
>
> On Thu, Nov 5, 2009 at 9:08 AM, Ernest Friedman-Hill <ejfried@...
> >wrote:
>
> > You don't show the connection between the Java calls to "store()" and
> where
> > Jess reads the module2.txt file. Are you sure it's the same instance of
> > jess.Rete that's involved in both? In other words, where and how is
> "batch
> > module2.txt" being invoked? Each Rete object will have its own
> independent
> > storage map.
> >
> > If it is the same Rete object, then perhaps there's a call to "clear"
> > somewhere in between the store and fetch?
> >
> >
> >
> >
> > On Nov 5, 2009, at 8:47 AM, Weijing Bai wrote:
> >
> >  oh,Thanks for your advice.
> >>
> >>
> >> my java code:
> >>
> >>  Rete engine = new Rete();
> >>  engine.store("m", 7);
> >>  engine.store("n", 5);
> >>
> >> the jess clp:
> >> " module2.txt"
> >>
> >> (defglobal ?*m* = (fetch m ))
> >> (defglobal ?*n* = (fetch n ))
> >>
> >> (printout t"?m = " ?*m* crlf)
> >> (printout t"?n = "  ?*n*  crlf)
> >>
> >> (bind ?I (div ?*m* 2 ))
> >> (bind ?J (+ ?*m*  ?*n* 2 ))
> >> (bind ?J'(+ (div  (+ ?*m*  1) 2) 1))
> >> (bind ?K (+ ?*m*   2 ))
> >> (bind ?L (+ (div (- ?*m*  3) 2) 3))
> >>
> >>
> >> the error message:
> >>
> >> ?m = nil
> >> ?n = nil
> >> Exception in thread "main" Jess reported an error in routine
> >> Value.intValue
> >> while executing (div ?*m* 2)
> >> while executing (bind ?I (div ?*m* 2))
> >> while executing (batch D:Jess71p1\module2.txt)
> >>  Message: 'nil' is a symbol, not  an integer.
> >>
> >>
> >> what's more, I once want use this in my java code, it did not work also:
> >> java code:
> >>
> >>  Rete engine = new Rete();
> >>
> >> engine.eval("(defglobal ?*m* = 7)");
> >> engine.eval("(defglobal ?*n* = 5)");
> >>
> >> "module2.txt":
> >>
> >> (printout t"?m = " ?*m* crlf)
> >> (printout t"?n = "  ?*n*  crlf)
> >>
> >> reports error:
> >> while executing (printout t "?m = " ?*m* crlf)
> >> while executing (batch D:\module2.txt)
> >>  Message: No such variable *m*.
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> On Thu, Nov 5, 2009 at 9:19 PM, Ernest Friedman-Hill <
> ejfried@...
> >> >wrote:
> >>
> >>  I think if you just show us the actual code that caused the error, and
> >>> more
> >>> details about the error -- i.e., is this a runtime or compile-time
> error,
> >>> from Java or from Jess, and include a stack trace -- I'm sure we can
> help
> >>> you fix it. Please cut and paste the real code, and the real stack
> trace
> >>> --
> >>> summaries and remembered bits and piece are normally not that helpful



--
Cheers,
Jason
----------------------------------------------------------
Morris Technical Solutions LLC
consulting@...
(517) 304-5883