Hi,
I am having a similar issue. It appears that GAE doesn't always return the
the script engine, for I get a NULL Exception. My code looks like:
public double myEval(String JsFormulaStr ) {
double solutionValue = 0;
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine eng = mgr.getEngineByName("JavaScript");
if(eng == null) { // Added this block of code to prevent
java.lang.NullPointerExceptoin...
log.severe("Unable to get Script Engine." );
return 0;
}
try {
Object jsResults = eng.eval(JsFormulaStr);
solutionValue = Double.parseDouble(jsResults.toString());
return solutionValue;
} catch(Exception e) {
log.severe("[ERROR] in
getCalculatedSolution_FromJS_ToDouble()::\n\t" +
"Formula String is: " + JsFormulaStr + "\n\t" + e);
return 0;
}
}
Everything works fine if I run it locally as a WebApp (Both in Eclipse &
Netbeans. And within Tomcat & Glassfish 4.0).
Some of the strings which I tried to eval:
- 62.0 / 100
- 0.0 * 352.0
- (0 - 428) * 1000
- (0 - 597) * 1000
- 73.0 / 100
NOTE: The '0' or '0.0' is from other evaluations. Since the function
returns 0 on an exception.
Thanks,
Randy
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/d/optout.