Starting a process from within a Servlet

I'm trying to run a Groovy script from within a servlet.
For this a wrote a class which used on its own, outside the servlet container,
works perfectly fine.
However, if it is used inside the servlet container (Tomcat by the way),
it does not work at all.

It seems to me, that there are some problems with the environment.
But also setting the path for the groovy executable didn't seem to do the trick.

Here is the code:

When run inside the servlet container this results in the following output:

I'm doing this on Windows and that "option Files" probably comes from "C:\Program Files\...".
I don't know where exactly the problem lies, especially as it only occurs when run inside the servlet container.

That "jvm creation failed" puzzles me. Is it possible, that the groovy executable is actually executed but then
groovy lacks some environment variables or why is there something about a JVM being created?

I'd imagine it's because of the space in the path, causing the command line processor to separate the command line parameters. You'd need to quote it.

That said--given that there are better ways to run Groovy from inside a Java program, this seems like a Really Bad way to do it.

Markus Kahl

Greenhorn

Posts: 5

posted 7 years ago

I actually tried that first.
But again I had problems. With the same code I could run the groovy script
in a stand-alone J2SE app but when run inside the servlet container it didn't work.
The code that is supposed to run the script is called but nothing happens.