File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Starting a process from within a Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Starting a process from within a Servlet" Watch "Starting a process from within a Servlet" New topic
Author

Starting a process from within a Servlet

Markus Kahl
Greenhorn

Joined: Apr 05, 2010
Posts: 5
Hey,

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:

Unrecognized option: Files
error: jvm creation failed with code -1: unknown error


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?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Apr 05, 2010
Posts: 5
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.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Starting a process from within a Servlet