Kawa fails in JavaEE

Daniele Benegiamo danielebenegiamo@fastwebnet.it
Wed Jul 21 11:43:00 GMT 2010


I'm trying to use Kawa (v. 1.9.90) for scripting in a JavaEE project (in
both EJB and JSF layers).

While in tests done with JavaSE all is fine, when I have moved to JavaEE
(Glassfish 3.0.1) the same code break; reporting a NPE. The test project
is a simple WAR+EJB, EJB is empty while WAR contains a single JSF page
that should print the result of parsing a simple Scheme program, parsing
done in a simple JSF Managed Bean.


Trying to parse a Scheme file using LispReader.readObject():


Caused by: java.lang.NullPointerException
         at
gnu.mapping.InheritingEnvironment.lookupInherited(InheritingEnvironment.java:72)
         at
gnu.mapping.InheritingEnvironment.getLocation(InheritingEnvironment.java:100)
         at gnu.mapping.Environment.getLocation(Environment.java:117)
         at gnu.mapping.ThreadLocation.getLocation(ThreadLocation.java:99)
         at gnu.mapping.ThreadLocation.get(ThreadLocation.java:132)
         at gnu.kawa.lispexpr.ReadTable.getCurrent(ReadTable.java:179)
         at gnu.kawa.lispexpr.LispReader.readObject(LispReader.java:240)


Trying to parse a Scheme file using Scheme.parse():


Caused by: java.lang.NullPointerException
         at
gnu.mapping.InheritingEnvironment.lookupInherited(InheritingEnvironment.java:72)
         at
gnu.mapping.InheritingEnvironment.getLocation(InheritingEnvironment.java:100)
         at gnu.mapping.Environment.getLocation(Environment.java:117)
         at gnu.mapping.ThreadLocation.getLocation(ThreadLocation.java:99)
         at gnu.mapping.ThreadLocation.get(ThreadLocation.java:132)
         at gnu.mapping.Location.get(Location.java:65)
         at gnu.expr.Compilation.getCurrent(Compilation.java:2855)
         at gnu.kawa.lispexpr.LispLanguage.parse(LispLanguage.java:51)
         at gnu.expr.Language.parse(Language.java:503)
         at gnu.expr.Language.parse(Language.java:467)


After inspecting, the "InheritingEnvironment.inherited" array contains
all "nulls". The first "null" come to the constructor, called from
"CallContext.getEnvironment()" that passes as argument
"Environment.global" that is null.

Unfortunately the problem is not always reproducible (but fails 95% of
times) and I think it's related to the usage of ThreadLocal et simila,
as JavaEE have strange requirements about threads and their usage (e.g.
if I remember correctly, EJBs can't spawn threads).

Someone have successfully used Kawa in a JavaEE environment? Otherwise
how/where can code be modified to work also in that environment?


Regards,
	Daniele.



More information about the Kawa mailing list