JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

Hunter Mcmillen
I am receiving the error in the subject line when one of my rules is firing. I can't seem to find any other forum posts about it, here is my rule:

(defrule build-supply-depot
(minerals (value ?x&:(> ?x 100)))
=>
(try 
(foreach ?u (?*bwapi* getMyUnits)
(if (= (?u getTypeID) ?*SCV_ID*) then
(bind ?p (call get-next-build-tile()))
(call ?*bwapi* drawCircle ?p.x ?p.y 100 111 FALSE FALSE)
(call ?*bwapi* build (?u getID) ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
(break)))
catch
(printout t (call ?ERROR toString) crlf)
)
)

and here is the exact error message:

        while executing (foreach ?u (call ?*bwapi* getMyUnits) 
                                   (if (= (call ?u getTypeID) ?*SCV_ID*) then 
                                   (bind ?p (call get-next-build-tile )) 
                                   (call ?*bwapi* drawCircle ?p.x ?p.y 100 111 FALSE FALSE) 
                                   (call ?*bwapi* build (call ?u getID) ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal)) 
                                   (break))).

  Message: '' is a list, not  a string.

But the error doesn't give me a line number. 

Any help would be appreciated.
Thanks,
Hunter McMillen
Reply | Threaded
Open this post in threaded view
|

Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

Wolfgang Laun-2
Are you sure that
   (?*bwapi* getMyUnits)
returns a list?

Jess' foreach isn't quite as tolerant as for in Java 1.5 and later.
You may have to return an java.util.iterator.

-W


On 10/03/2012, Hunter McMillen <[hidden email]> wrote:

> I am receiving the error in the subject line when one of my rules is
> firing. I can't seem to find any other forum posts about it, here is my
> rule:
>
> (defrule build-supply-depot
> (minerals (value ?x&:(> ?x 100)))
> =>
> (try
> (foreach ?u (?*bwapi* getMyUnits)
> (if (= (?u getTypeID) ?*SCV_ID*) then
> (bind ?p (call get-next-build-tile()))
> (call ?*bwapi* drawCircle ?p.x ?p.y 100 111 FALSE FALSE)
> (call ?*bwapi* build (?u getID) ?p.x ?p.y
> (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
> (break)))
> catch
> (printout t (call ?ERROR toString) crlf)
> )
> )
>
> and here is the exact error message:
>
>         while executing (foreach ?u (call ?*bwapi* getMyUnits)
>                                    (if (= (call ?u getTypeID) ?*SCV_ID*)
> then
>                                    (bind ?p (call get-next-build-tile ))
>                                    (call ?*bwapi* drawCircle ?p.x ?p.y 100
> 111 FALSE FALSE)
>                                    (call ?*bwapi* build (call ?u getID)
> ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
>                                    (break))).
>
>   Message: '' is a list, not  a string.
>
> But the error doesn't give me a line number.
>
> Any help would be appreciated.
> Thanks,
> Hunter McMillen
>

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [hidden email]'
in the BODY of a message to [hidden email], NOT to the list
(use your own address!) List problems? Notify [hidden email].
--------------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

Hunter Mcmillen
Thanks for your response Wolfgang, 

Yes, getMyUnits() returns an ArrayList<Unit>; I don't believe this likely to be the problem since I have these in other rules that are functioning. 
More debugging shows that the error is occurring in routine Value.stringValue. Do you see anywhere where I am trying to get the string value of a list?

Hunter 
On Mon, Mar 12, 2012 at 9:38 AM, Wolfgang Laun <[hidden email]> wrote:
Are you sure that
  (?*bwapi* getMyUnits)
returns a list?

Jess' foreach isn't quite as tolerant as for in Java 1.5 and later.
You may have to return an java.util.iterator.

-W


On 10/03/2012, Hunter McMillen <[hidden email]> wrote:
> I am receiving the error in the subject line when one of my rules is
> firing. I can't seem to find any other forum posts about it, here is my
> rule:
>
> (defrule build-supply-depot
> (minerals (value ?x&:(> ?x 100)))
> =>
> (try
> (foreach ?u (?*bwapi* getMyUnits)
> (if (= (?u getTypeID) ?*SCV_ID*) then
> (bind ?p (call get-next-build-tile()))
> (call ?*bwapi* drawCircle ?p.x ?p.y 100 111 FALSE FALSE)
> (call ?*bwapi* build (?u getID) ?p.x ?p.y
> (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
> (break)))
> catch
> (printout t (call ?ERROR toString) crlf)
> )
> )
>
> and here is the exact error message:
>
>         while executing (foreach ?u (call ?*bwapi* getMyUnits)
>                                    (if (= (call ?u getTypeID) ?*SCV_ID*)
> then
>                                    (bind ?p (call get-next-build-tile ))
>                                    (call ?*bwapi* drawCircle ?p.x ?p.y 100
> 111 FALSE FALSE)
>                                    (call ?*bwapi* build (call ?u getID)
> ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
>                                    (break))).
>
>   Message: '' is a list, not  a string.
>
> But the error doesn't give me a line number.
>
> Any help would be appreciated.
> Thanks,
> Hunter McMillen
>

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [hidden email]'
in the BODY of a message to [hidden email], NOT to the list
(use your own address!) List problems? Notify [hidden email].
--------------------------------------------------------------------


Reply | Threaded
Open this post in threaded view
|

Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

Jason Morris
The other place that it might be is in the line

 (if (= (call ?u getTypeID) ?*SCV_ID*) then ...

because the "=" function does a comparison by value, so it would likely use Value.getValue().

What do your ID's look like?  Are they numbers or strings, or something else?
If they are strings, then you need to use "eq" not "=".  If they are some object, then the type has to implement Comparable so that the value comparison can be made.

Also, there might be some side effects of the "call" function that you keep using.  Particularly that Jess returns coerces Arrays into lists.  Really, you only need it for calling static methods on classes.  See the Description for call in the jess docs.  ".. When calling Java methods, arguments are promoted and overloaded methods selected precisely as for new. The return value is converted to a suitable Jess value before being returned. Array return values are converted to lists. "

On Tue, Mar 13, 2012 at 1:43 AM, Hunter McMillen <[hidden email]> wrote:
Thanks for your response Wolfgang, 

Yes, getMyUnits() returns an ArrayList<Unit>; I don't believe this likely to be the problem since I have these in other rules that are functioning. 
More debugging shows that the error is occurring in routine Value.stringValue. Do you see anywhere where I am trying to get the string value of a list?

Hunter 

On Mon, Mar 12, 2012 at 9:38 AM, Wolfgang Laun <[hidden email]> wrote:
Are you sure that
  (?*bwapi* getMyUnits)
returns a list?

Jess' foreach isn't quite as tolerant as for in Java 1.5 and later.
You may have to return an java.util.iterator.

-W


On 10/03/2012, Hunter McMillen <[hidden email]> wrote:
> I am receiving the error in the subject line when one of my rules is
> firing. I can't seem to find any other forum posts about it, here is my
> rule:
>
> (defrule build-supply-depot
> (minerals (value ?x&:(> ?x 100)))
> =>
> (try
> (foreach ?u (?*bwapi* getMyUnits)
> (if (= (?u getTypeID) ?*SCV_ID*) then
> (bind ?p (call get-next-build-tile()))
> (call ?*bwapi* drawCircle ?p.x ?p.y 100 111 FALSE FALSE)
> (call ?*bwapi* build (?u getID) ?p.x ?p.y
> (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
> (break)))
> catch
> (printout t (call ?ERROR toString) crlf)
> )
> )
>
> and here is the exact error message:
>
>         while executing (foreach ?u (call ?*bwapi* getMyUnits)
>                                    (if (= (call ?u getTypeID) ?*SCV_ID*)
> then
>                                    (bind ?p (call get-next-build-tile ))
>                                    (call ?*bwapi* drawCircle ?p.x ?p.y 100
> 111 FALSE FALSE)
>                                    (call ?*bwapi* build (call ?u getID)
> ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
>                                    (break))).
>
>   Message: '' is a list, not  a string.
>
> But the error doesn't give me a line number.
>
> Any help would be appreciated.
> Thanks,
> Hunter McMillen
>

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [hidden email]'
in the BODY of a message to [hidden email], NOT to the list
(use your own address!) List problems? Notify [hidden email].
--------------------------------------------------------------------





--
Jason C. Morris
President, Principal Consultant
Morris Technical Solutions LLC
President, Rules Fest Association
Chairman, IntelliFest 2012: International Conference on Reasoning Technologies

--------------------------------------------
phone: +01.517.304.5883
skype: jcmorris-mts
email: [hidden email]
mybio: http://www.linkedin.com/in/jcmorris



www.intellifest.org
Invent * Innovate * Implement at IntelliFest!

Reply | Threaded
Open this post in threaded view
|

Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

Friedman-Hill, Ernest
In reply to this post by Hunter Mcmillen
Hmmm. If that's the whole error message, then the error should be occurring executing that "foreach" function, not a function nested inside it; otherwise there would be more context information. But "foreach" doesn't try to coerce anything into a string, so that doesn't make sense.

Inside your catch block,  do this:

(?ERROR printStackTrace)

And show us what you get; that should narrow it down quite a bit.


From: Hunter McMillen <[hidden email]>
Reply-To: <[hidden email]>
Date: Fri, 9 Mar 2012 23:10:06 -0500
To: <[hidden email]>
Subject: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

I am receiving the error in the subject line when one of my rules is firing. I can't seem to find any other forum posts about it, here is my rule:

(defrule build-supply-depot
(minerals (value ?x&:(> ?x 100)))
=>
(try 
(foreach ?u (?*bwapi* getMyUnits)
(if (= (?u getTypeID) ?*SCV_ID*) then
(bind ?p (call get-next-build-tile()))
(call ?*bwapi* drawCircle ?p.x ?p.y 100 111 FALSE FALSE)
(call ?*bwapi* build (?u getID) ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
(break)))
catch
(printout t (call ?ERROR toString) crlf)
)
)

and here is the exact error message:

        while executing (foreach ?u (call ?*bwapi* getMyUnits) 
                                   (if (= (call ?u getTypeID) ?*SCV_ID*) then 
                                   (bind ?p (call get-next-build-tile )) 
                                   (call ?*bwapi* drawCircle ?p.x ?p.y 100 111 FALSE FALSE) 
                                   (call ?*bwapi* build (call ?u getID) ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal)) 
                                   (break))).

  Message: '' is a list, not  a string.

But the error doesn't give me a line number. 

Any help would be appreciated.
Thanks,
Hunter McMillen
Reply | Threaded
Open this post in threaded view
|

Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

Hunter Mcmillen
Here is the stacktrace: 
 Message: '' is a list, not  a string.
       at jess.Value.a(Unknown Source)
       at jess.Value.a(Unknown Source)
       at jess.Value.a(Unknown Source)
       at jess.Value.stringValue(Unknown Source)
       at jess.Value.symbolValue(Unknown Source)
       at jess.dx.call(Unknown Source)
       at jess.ac.a(Unknown Source)
       at jess.Funcall.execute(Unknown Source)
       at jess.FuncallValue.resolveValue(Unknown Source)
       at jess.ce.call(Unknown Source)
       at jess.ac.a(Unknown Source)
       at jess.Funcall.execute(Unknown Source)
       at jess.FuncallValue.resolveValue(Unknown Source)
       at jess.f4.call(Unknown Source)
       at jess.ac.a(Unknown Source)
       at jess.Funcall.execute(Unknown Source)
       at jess.FuncallValue.resolveValue(Unknown Source)
       at jess.cu.a(Unknown Source)
       at jess.cu.call(Unknown Source)
       at jess.ac.a(Unknown Source)
       at jess.Funcall.execute(Unknown Source)
       at jess.FuncallValue.resolveValue(Unknown Source)
       at jess.i.call(Unknown Source)
       at jess.ac.a(Unknown Source)
       at jess.Funcall.execute(Unknown Source)
       at jess.Defrule.a(Unknown Source)
       at jess.Activation.a(Unknown Source)
       at jess.en.a(Unknown Source)
       at jess.en.a(Unknown Source)
       at jess.Rete.if(Unknown Source)
       at jess.Rete.run(Unknown Source)
       at hunterai.HunterAIClient.gameUpdate(HunterAIClient.java:156)
       at eisbot.proxy.JNIBWAPI.gameUpdate(JNIBWAPI.java:795)
       at eisbot.proxy.JNIBWAPI.startClient(Native Method)
       at eisbot.proxy.JNIBWAPI.start(JNIBWAPI.java:597)
       at hunterai.HunterAIClient.start(HunterAIClient.java:102)
       at hunterai.HunterAIClient.main(HunterAIClient.java:42)

The first line in my code that the trace lists is where I run the engine from my Java application:

       engine.run();


Hunter

On Mon, Mar 12, 2012 at 11:40 AM, Friedman-Hill, Ernest <[hidden email]> wrote:
Hmmm. If that's the whole error message, then the error should be occurring executing that "foreach" function, not a function nested inside it; otherwise there would be more context information. But "foreach" doesn't try to coerce anything into a string, so that doesn't make sense.

Inside your catch block,  do this:

(?ERROR printStackTrace)

And show us what you get; that should narrow it down quite a bit.


From: Hunter McMillen <[hidden email]>
Reply-To: <[hidden email]>
Date: Fri, 9 Mar 2012 23:10:06 -0500
To: <[hidden email]>
Subject: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

I am receiving the error in the subject line when one of my rules is firing. I can't seem to find any other forum posts about it, here is my rule:

(defrule build-supply-depot
(minerals (value ?x&:(> ?x 100)))
=>
(try 
(foreach ?u (?*bwapi* getMyUnits)
(if (= (?u getTypeID) ?*SCV_ID*) then
(bind ?p (call get-next-build-tile()))
(call ?*bwapi* drawCircle ?p.x ?p.y 100 111 FALSE FALSE)
(call ?*bwapi* build (?u getID) ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
(break)))
catch
(printout t (call ?ERROR toString) crlf)
)
)

and here is the exact error message:

        while executing (foreach ?u (call ?*bwapi* getMyUnits) 
                                   (if (= (call ?u getTypeID) ?*SCV_ID*) then 
                                   (bind ?p (call get-next-build-tile )) 
                                   (call ?*bwapi* drawCircle ?p.x ?p.y 100 111 FALSE FALSE) 
                                   (call ?*bwapi* build (call ?u getID) ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal)) 
                                   (break))).

  Message: '' is a list, not  a string.

But the error doesn't give me a line number. 

Any help would be appreciated.
Thanks,
Hunter McMillen

Reply | Threaded
Open this post in threaded view
|

Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

Friedman-Hill, Ernest
OK, I looked in the magic decoder file and I see a "call" being invoked inside a "bind", so that fits only the line of code below. And lo and behold, look at it: the second argument to "call", which should be the name of the function to call, is a pair of empty parentheses — i.e., a list. This line is asking Jess to to call the static method named "()" on the class named "get-next-build-tile" -- surely not what you intended. If you're just calling a deffunction by this name, then you just want

(bind ?p (get-next-build-tile))

From: Hunter McMillen <[hidden email]>
Reply-To: <[hidden email]>
Date: Mon, 12 Mar 2012 12:16:29 -0400
To: <[hidden email]>
Subject: Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

(bind ?p (call get-next-build-tile()))

Reply | Threaded
Open this post in threaded view
|

Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

Hunter Mcmillen
That was exactly the problem, thanks. What is the general rule for function calling in Jess, always without parentheses? I never would have caught that error because when I see something like get-next-build-tile() the parentheses tell me it is a function. Seeing it without the parens makes me think it is a variable, even without the ? sign is front. 

Also, as a corollary question; I am using an enumerated type in my rule:

(import eisbot.proxy.types.UnitType$UnitTypes)

(defrule build-supply-depot
(minerals (value ?x&:(> ?x 100)))
=>
(try 
(foreach ?u (?*bwapi* getMyUnits)
(if (= (?u getTypeID) ?*SCV_ID*) then
(bind ?p (call get-next-build-tile()))
(call ?*bwapi* drawCircle ?p.x ?p.y 100 111 FALSE FALSE)
(call ?*bwapi* build (?u getID) ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
(break)))
catch
(printout t (call ?ERROR toString) crlf)
)
)

But after importing when my rule tries to execute the bolded line above, I get a class not found exception:

  Message: Class not found.
        at jess.dx.call(Unknown Source)
        at jess.ac.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.FuncallValue.resolveValue(Unknown Source)
        at jess.dx.call(Unknown Source)
        at jess.ac.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.FuncallValue.resolveValue(Unknown Source)
        at jess.f4.call(Unknown Source)
        at jess.ac.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.FuncallValue.resolveValue(Unknown Source)
        at jess.cu.a(Unknown Source)
        at jess.cu.call(Unknown Source)
        at jess.ac.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.Defrule.a(Unknown Source)
        at jess.Activation.a(Unknown Source)
        at jess.en.a(Unknown Source)
        at jess.en.a(Unknown Source)
        at jess.Rete.if(Unknown Source)
        at jess.Rete.run(Unknown Source)
        at hunterai.HunterAIClient.gameUpdate(HunterAIClient.java:156)
        at eisbot.proxy.JNIBWAPI.gameUpdate(JNIBWAPI.java:795)
        at eisbot.proxy.JNIBWAPI.startClient(Native Method)
        at eisbot.proxy.JNIBWAPI.start(JNIBWAPI.java:597)
        at hunterai.HunterAIClient.start(HunterAIClient.java:102)
        at hunterai.HunterAIClient.main(HunterAIClient.java:42)
Caused by: java.lang.ClassNotFoundException: new
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.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 java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at jess.dc.for(Unknown Source)
        at jess.dc.if(Unknown Source)
        at jess.Rete.findClass(Unknown Source)
        ... 28 more

any ideas?

Hunter


 

On Mon, Mar 12, 2012 at 1:48 PM, Friedman-Hill, Ernest <[hidden email]> wrote:
OK, I looked in the magic decoder file and I see a "call" being invoked inside a "bind", so that fits only the line of code below. And lo and behold, look at it: the second argument to "call", which should be the name of the function to call, is a pair of empty parentheses — i.e., a list. This line is asking Jess to to call the static method named "()" on the class named "get-next-build-tile" -- surely not what you intended. If you're just calling a deffunction by this name, then you just want

(bind ?p (get-next-build-tile))

From: Hunter McMillen <[hidden email]>
Reply-To: <[hidden email]>
Date: Mon, 12 Mar 2012 12:16:29 -0400
To: <[hidden email]>
Subject: Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

(bind ?p (call get-next-build-tile()))


Reply | Threaded
Open this post in threaded view
|

Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

Friedman-Hill, Ernest
The Jess language is not Java, it's Lisp by design, and parentheses just work differently. All functions calls look like (fooFunction a b c), and if there's no arguments, it's just (fooFunction). There are never parentheses just surrounding the arguments.

For using enums, look here: http://www.jessrules.com/jesswiki/view?EnumeratedTypes . The upshot is that "import" will defined some functions for you which return the enum's values; to get the value, you have to call the function. So there's one more set of parentheses:

   ((UnitType$UnitTypes.Terran_Supply_Depot) ordinal)



From: Hunter McMillen <[hidden email]>
Reply-To: <[hidden email]>
Date: Mon, 12 Mar 2012 15:59:45 -0400
To: <[hidden email]>
Subject: Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

That was exactly the problem, thanks. What is the general rule for function calling in Jess, always without parentheses? I never would have caught that error because when I see something like get-next-build-tile() the parentheses tell me it is a function. Seeing it without the parens makes me think it is a variable, even without the ? sign is front. 

Also, as a corollary question; I am using an enumerated type in my rule:

(import eisbot.proxy.types.UnitType$UnitTypes)

(defrule build-supply-depot
(minerals (value ?x&:(> ?x 100)))
=>
(try 
(foreach ?u (?*bwapi* getMyUnits)
(if (= (?u getTypeID) ?*SCV_ID*) then
(bind ?p (call get-next-build-tile()))
(call ?*bwapi* drawCircle ?p.x ?p.y 100 111 FALSE FALSE)
(call ?*bwapi* build (?u getID) ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
(break)))
catch
(printout t (call ?ERROR toString) crlf)
)
)

But after importing when my rule tries to execute the bolded line above, I get a class not found exception:

  Message: Class not found.
        at jess.dx.call(Unknown Source)
        at jess.ac.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.FuncallValue.resolveValue(Unknown Source)
        at jess.dx.call(Unknown Source)
        at jess.ac.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.FuncallValue.resolveValue(Unknown Source)
        at jess.f4.call(Unknown Source)
        at jess.ac.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.FuncallValue.resolveValue(Unknown Source)
        at jess.cu.a(Unknown Source)
        at jess.cu.call(Unknown Source)
        at jess.ac.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.Defrule.a(Unknown Source)
        at jess.Activation.a(Unknown Source)
        at jess.en.a(Unknown Source)
        at jess.en.a(Unknown Source)
        at jess.Rete.if(Unknown Source)
        at jess.Rete.run(Unknown Source)
        at hunterai.HunterAIClient.gameUpdate(HunterAIClient.java:156)
        at eisbot.proxy.JNIBWAPI.gameUpdate(JNIBWAPI.java:795)
        at eisbot.proxy.JNIBWAPI.startClient(Native Method)
        at eisbot.proxy.JNIBWAPI.start(JNIBWAPI.java:597)
        at hunterai.HunterAIClient.start(HunterAIClient.java:102)
        at hunterai.HunterAIClient.main(HunterAIClient.java:42)
Caused by: java.lang.ClassNotFoundException: new
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.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 java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at jess.dc.for(Unknown Source)
        at jess.dc.if(Unknown Source)
        at jess.Rete.findClass(Unknown Source)
        ... 28 more

any ideas?

Hunter


 

On Mon, Mar 12, 2012 at 1:48 PM, Friedman-Hill, Ernest <[hidden email]> wrote:
OK, I looked in the magic decoder file and I see a "call" being invoked inside a "bind", so that fits only the line of code below. And lo and behold, look at it: the second argument to "call", which should be the name of the function to call, is a pair of empty parentheses — i.e., a list. This line is asking Jess to to call the static method named "()" on the class named "get-next-build-tile" -- surely not what you intended. If you're just calling a deffunction by this name, then you just want

(bind ?p (get-next-build-tile))

From: Hunter McMillen <[hidden email]>
Reply-To: <[hidden email]>
Date: Mon, 12 Mar 2012 12:16:29 -0400
To: <[hidden email]>
Subject: Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

(bind ?p (call get-next-build-tile()))


Reply | Threaded
Open this post in threaded view
|

Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

Jason Morris
Good gravy!  This is one of those "can't see the forest through the trees" examples that we used to collect on the jess wiki!  It was hiding in plain sight!

One lesson from this is that Jess's error messages, even when seemingly cryptic, contain some useful clues. Users, myself included, are too often guilty of assuming that the message isn't useful or is mistaken when the reality is the opposite.  Also, there was an indirect side-effect of using call .. namely not knowing what arguments it was expecting.

On Tue, Mar 13, 2012 at 7:23 AM, Friedman-Hill, Ernest <[hidden email]> wrote:
The Jess language is not Java, it's Lisp by design, and parentheses just work differently. All functions calls look like (fooFunction a b c), and if there's no arguments, it's just (fooFunction). There are never parentheses just surrounding the arguments.

For using enums, look here: http://www.jessrules.com/jesswiki/view?EnumeratedTypes . The upshot is that "import" will defined some functions for you which return the enum's values; to get the value, you have to call the function. So there's one more set of parentheses:

   ((UnitType$UnitTypes.Terran_Supply_Depot) ordinal)



From: Hunter McMillen <[hidden email]>
Reply-To: <[hidden email]>
Date: Mon, 12 Mar 2012 15:59:45 -0400

To: <[hidden email]>
Subject: Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

That was exactly the problem, thanks. What is the general rule for function calling in Jess, always without parentheses? I never would have caught that error because when I see something like get-next-build-tile() the parentheses tell me it is a function. Seeing it without the parens makes me think it is a variable, even without the ? sign is front. 

Also, as a corollary question; I am using an enumerated type in my rule:

(import eisbot.proxy.types.UnitType$UnitTypes)

(defrule build-supply-depot
(minerals (value ?x&:(> ?x 100)))
=>
(try 
(foreach ?u (?*bwapi* getMyUnits)
(if (= (?u getTypeID) ?*SCV_ID*) then
(bind ?p (call get-next-build-tile()))
(call ?*bwapi* drawCircle ?p.x ?p.y 100 111 FALSE FALSE)
(call ?*bwapi* build (?u getID) ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
(break)))
catch
(printout t (call ?ERROR toString) crlf)
)
)

But after importing when my rule tries to execute the bolded line above, I get a class not found exception:

  Message: Class not found.
        at jess.dx.call(Unknown Source)
        at jess.ac.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.FuncallValue.resolveValue(Unknown Source)
        at jess.dx.call(Unknown Source)
        at jess.ac.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.FuncallValue.resolveValue(Unknown Source)
        at jess.f4.call(Unknown Source)
        at jess.ac.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.FuncallValue.resolveValue(Unknown Source)
        at jess.cu.a(Unknown Source)
        at jess.cu.call(Unknown Source)
        at jess.ac.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.Defrule.a(Unknown Source)
        at jess.Activation.a(Unknown Source)
        at jess.en.a(Unknown Source)
        at jess.en.a(Unknown Source)
        at jess.Rete.if(Unknown Source)
        at jess.Rete.run(Unknown Source)
        at hunterai.HunterAIClient.gameUpdate(HunterAIClient.java:156)
        at eisbot.proxy.JNIBWAPI.gameUpdate(JNIBWAPI.java:795)
        at eisbot.proxy.JNIBWAPI.startClient(Native Method)
        at eisbot.proxy.JNIBWAPI.start(JNIBWAPI.java:597)
        at hunterai.HunterAIClient.start(HunterAIClient.java:102)
        at hunterai.HunterAIClient.main(HunterAIClient.java:42)
Caused by: java.lang.ClassNotFoundException: new
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.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 java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at jess.dc.for(Unknown Source)
        at jess.dc.if(Unknown Source)
        at jess.Rete.findClass(Unknown Source)
        ... 28 more

any ideas?

Hunter


 

On Mon, Mar 12, 2012 at 1:48 PM, Friedman-Hill, Ernest <[hidden email]> wrote:
OK, I looked in the magic decoder file and I see a "call" being invoked inside a "bind", so that fits only the line of code below. And lo and behold, look at it: the second argument to "call", which should be the name of the function to call, is a pair of empty parentheses — i.e., a list. This line is asking Jess to to call the static method named "()" on the class named "get-next-build-tile" -- surely not what you intended. If you're just calling a deffunction by this name, then you just want

(bind ?p (get-next-build-tile))

From: Hunter McMillen <[hidden email]>
Reply-To: <[hidden email]>
Date: Mon, 12 Mar 2012 12:16:29 -0400
To: <[hidden email]>
Subject: Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

(bind ?p (call get-next-build-tile()))





--
Jason C. Morris
President, Principal Consultant
Morris Technical Solutions LLC
President, Rules Fest Association
Chairman, IntelliFest 2012: International Conference on Reasoning Technologies

--------------------------------------------
phone: +01.517.304.5883
skype: jcmorris-mts
email: [hidden email]
mybio: http://www.linkedin.com/in/jcmorris



www.intellifest.org
Invent * Innovate * Implement at IntelliFest!

Reply | Threaded
Open this post in threaded view
|

Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

Wolfgang Laun-2
In reply to this post by Friedman-Hill, Ernest
If you rely heavily on enums, you might consider using a userfunction
that binds enum constants to Jess variables - so you don't need the
parentheses.

http://www.jessrules.com/jesswiki/view?BindEnumUserFunction

-W

On 12/03/2012, Friedman-Hill, Ernest <[hidden email]> wrote:

> The Jess language is not Java, it's Lisp by design, and parentheses just
> work differently. All functions calls look like (fooFunction a b c), and if
> there's no arguments, it's just (fooFunction). There are never parentheses
> just surrounding the arguments.
>
> For using enums, look here:
> http://www.jessrules.com/jesswiki/view?EnumeratedTypes . The upshot is that
> "import" will defined some functions for you which return the enum's values;
> to get the value, you have to call the function. So there's one more set of
> parentheses:
>
>    ((UnitType$UnitTypes.Terran_Supply_Depot) ordinal)
>
>
>
> From: Hunter McMillen <[hidden email]<mailto:[hidden email]>>
> Reply-To: <[hidden email]<mailto:[hidden email]>>
> Date: Mon, 12 Mar 2012 15:59:45 -0400
> To: <[hidden email]<mailto:[hidden email]>>
> Subject: Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string
>
> That was exactly the problem, thanks. What is the general rule for function
> calling in Jess, always without parentheses? I never would have caught that
> error because when I see something like get-next-build-tile() the
> parentheses tell me it is a function. Seeing it without the parens makes me
> think it is a variable, even without the ? sign is front.
>
> Also, as a corollary question; I am using an enumerated type in my rule:
>
> (import eisbot.proxy.types.UnitType$UnitTypes)
>
> (defrule build-supply-depot
> (minerals (value ?x&:(> ?x 100)))
> =>
> (try
> (foreach ?u (?*bwapi* getMyUnits)
> (if (= (?u getTypeID) ?*SCV_ID*) then
> (bind ?p (call get-next-build-tile()))
> (call ?*bwapi* drawCircle ?p.x ?p.y 100 111 FALSE FALSE)
> (call ?*bwapi* build (?u getID) ?p.x ?p.y
> (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
> (break)))
> catch
> (printout t (call ?ERROR toString) crlf)
> )
> )
>
> But after importing when my rule tries to execute the bolded line above, I
> get a class not found exception:
>
>   Message: Class not found.
>         at jess.dx.call(Unknown Source)
>         at jess.ac.a(Unknown Source)
>         at jess.Funcall.execute(Unknown Source)
>         at jess.FuncallValue.resolveValue(Unknown Source)
>         at jess.dx.call(Unknown Source)
>         at jess.ac.a(Unknown Source)
>         at jess.Funcall.execute(Unknown Source)
>         at jess.FuncallValue.resolveValue(Unknown Source)
>         at jess.f4.call(Unknown Source)
>         at jess.ac.a(Unknown Source)
>         at jess.Funcall.execute(Unknown Source)
>         at jess.FuncallValue.resolveValue(Unknown Source)
>         at jess.cu.a(Unknown Source)
>         at jess.cu.call(Unknown Source)
>         at jess.ac.a(Unknown Source)
>         at jess.Funcall.execute(Unknown Source)
>         at jess.Defrule.a(Unknown Source)
>         at jess.Activation.a(Unknown Source)
>         at jess.en.a(Unknown Source)
>         at jess.en.a(Unknown Source)
>         at jess.Rete.if(Unknown Source)
>         at jess.Rete.run(Unknown Source)
>         at hunterai.HunterAIClient.gameUpdate(HunterAIClient.java:156)
>         at eisbot.proxy.JNIBWAPI.gameUpdate(JNIBWAPI.java:795)
>         at eisbot.proxy.JNIBWAPI.startClient(Native Method)
>         at eisbot.proxy.JNIBWAPI.start(JNIBWAPI.java:597)
>         at hunterai.HunterAIClient.start(HunterAIClient.java:102)
>         at hunterai.HunterAIClient.main(HunterAIClient.java:42)
> Caused by: java.lang.ClassNotFoundException: new
>         at java.net.URLClassLoader$1.run(Unknown Source)
>         at java.net.URLClassLoader$1.run(Unknown Source)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at java.net.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 java.lang.Class.forName0(Native Method)
>         at java.lang.Class.forName(Unknown Source)
>         at jess.dc.for(Unknown Source)
>         at jess.dc.if(Unknown Source)
>         at jess.Rete.findClass(Unknown Source)
>         ... 28 more
>
> any ideas?
>
> Hunter
>
>
>
>
> On Mon, Mar 12, 2012 at 1:48 PM, Friedman-Hill, Ernest
> <[hidden email]<mailto:[hidden email]>> wrote:
> OK, I looked in the magic decoder file and I see a "call" being invoked
> inside a "bind", so that fits only the line of code below. And lo and
> behold, look at it: the second argument to "call", which should be the name
> of the function to call, is a pair of empty parentheses — i.e., a list. This
> line is asking Jess to to call the static method named "()" on the class
> named "get-next-build-tile" -- surely not what you intended. If you're just
> calling a deffunction by this name, then you just want
>
> (bind ?p (get-next-build-tile))
>
> From: Hunter McMillen <[hidden email]<mailto:[hidden email]>>
> Reply-To: <[hidden email]<mailto:[hidden email]>>
> Date: Mon, 12 Mar 2012 12:16:29 -0400
> To: <[hidden email]<mailto:[hidden email]>>
> Subject: Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string
>
> (bind ?p (call get-next-build-tile()))
>
>
>



--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [hidden email]'
in the BODY of a message to [hidden email], NOT to the list
(use your own address!) List problems? Notify [hidden email].
--------------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

Wolfgang Laun-2
In reply to this post by Hunter Mcmillen
The posted error message still puzzles me. My recollection has it that
Jess reports quite accurately the statement where the exception was
raised, not just the outermost control statement. Moreover, all levels
between the outermost and innermost statement are displayed as well,
so that you can accurately trace the execution path.

If can provoke the reported error using this code:

(deffunction foo ())
(bind ?list (list a b c))
(try
  (foreach ?elem ?list
    (printout t ?elem crlf)
    (bind ?x (call foo ()))
  )
catch
  (printout t (call ?ERROR toString) crlf)
)

But I get this lucid information (Jess 7.1p2):

class jess.JessException
Jess reported an error in routine Value.stringValue
        while executing (call foo )
        while executing (bind ?x (call foo ))
        while executing (foreach ?elem ?list (printout t ?elem crlf) (bind ?x
(call foo ))).
  Message: '' is a list, not  a string.

Was the original post produced by some older Jess version?

-W

On 10/03/2012, Hunter McMillen <[hidden email]> wrote:

> I am receiving the error in the subject line when one of my rules is
> firing. I can't seem to find any other forum posts about it, here is my
> rule:
>
> (defrule build-supply-depot
> (minerals (value ?x&:(> ?x 100)))
> =>
> (try
> (foreach ?u (?*bwapi* getMyUnits)
> (if (= (?u getTypeID) ?*SCV_ID*) then
> (bind ?p (call get-next-build-tile()))
> (call ?*bwapi* drawCircle ?p.x ?p.y 100 111 FALSE FALSE)
> (call ?*bwapi* build (?u getID) ?p.x ?p.y
> (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
> (break)))
> catch
> (printout t (call ?ERROR toString) crlf)
> )
> )
>
> and here is the exact error message:
>
>         while executing (foreach ?u (call ?*bwapi* getMyUnits)
>                                    (if (= (call ?u getTypeID) ?*SCV_ID*)
> then
>                                    (bind ?p (call get-next-build-tile ))
>                                    (call ?*bwapi* drawCircle ?p.x ?p.y 100
> 111 FALSE FALSE)
>                                    (call ?*bwapi* build (call ?u getID)
> ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
>                                    (break))).
>
>   Message: '' is a list, not  a string.
>
> But the error doesn't give me a line number.
>
> Any help would be appreciated.
> Thanks,
> Hunter McMillen
>

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [hidden email]'
in the BODY of a message to [hidden email], NOT to the list
(use your own address!) List problems? Notify [hidden email].
--------------------------------------------------------------------