I am trying to understand the problem that I see with JSR223 scripts when working inside Tomcat. I use the Java scripting engine, but I believe that the problem is applied more generally (I also saw a similar problem with the reference JS engine). The skip script I pass for evaluation has this as the first line:
import javax.servlet.http.*;
This message is not executed:
package javax.servlet.http does not exist
So, delving into the source code of the Java script engine, I know why this happens - it passes my script text to JavaCompiler, specifying as it is the path to the classes that it extracted from java.class.path, but because Tomcat does its work as for the class of loaders and classpaths, the only thing that contains $CATALINA_HOME/bin/bootstrap.jar.
You can override the class path that will be used by the scripting engine, but this just presents me with my next problem - how can I detect at run time what Tomas claspath uses?
It seems that I should miss something obvious here, because, as far as I can tell, this will happen to anyone who is trying to make some serious script in a web application, and yet I was looking for hours to discuss in this area and not can find anyone even asking a question ...
source
share