users@glassfish.java.net

Re: Spawning a process from within web service.

From: <glassfish_at_javadesktop.org>
Date: Fri, 25 Jan 2008 16:52:21 PST

By default, Glassfish disables the security manager.

Are you getting any exceptions at all? Have you managed to get some kind of simple "hello world" working?

As a rule, might I suggest trying to find some other way to do this?

The only reason I say that is not so much that forking a process is "ugly", that's just reality.

But, it's important to note that if you're running a large Glassfish process (and, face it, most of them are large), forking that process is particularly expensive to do. This is because the first thing the system does to execute your command is duplicate the current process.

Now, granted, it's almost all done with virtual memory and copy on write pages etc, so it's as efficient as it can be, but it's STILL a complete, virtual copy of your process. If you're running a 500MB VM image (not difficult with glassfish), that's a lot of pages to flag and move, etc. And it has a decent impact on your system (particularly swap on Unix systems).

Mind, this is what GF does ANYWAY if you do something like compile a JSP (unless you're running java 6).

So, anyway, you may well be better off, albeit complicating the architecture, by writing a small, stand alone Java daemon program that listens on, say, a JMS queue. Then this little daemon itself runs the program, gathers any results, and send those back (via a queue) to the requester.

Just something to think about.
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=255897