-
1. Running external processes from JBoss
wdfink May 4, 2011 4:31 PM (in response to evyatarc)Manipulate threads, accessing java.IO or start external processes will be against the EJB spec.
Nevertheless I have seen it very often, but mostly with lot of problems related to this and sometimes with better aproaches conform to the spec after rethinking.
So what is your reason to start an external process?
-
2. Running external processes from JBoss
dimitris May 4, 2011 4:37 PM (in response to wdfink)1 of 1 people found this helpfulI think Mladen had writen some native utilities to let you do all sorts of this kind of things. I'll ping him...
-
3. Running external processes from JBoss
mladen.turk May 4, 2011 5:38 PM (in response to dimitris)1 of 1 people found this helpfulYep, and still working on it
The name of the game is Apache Commons Runtime and it's currently in the sanbox.I suppose the first release will be in couple of months.
One feature it has is the external process execution without using separate threads. However the current thread is blocked until the process exits if one needs to read its output. This is done internally by using native async I/O which works in the same thread.
It can also start the process as daemon (running in the backround) which can you check for state at any later time.
This should fit better for EJB (and other) containers that are not happy with starting whole bunch of execution threads.
-
4. Running external processes from JBoss
evyatarc May 5, 2011 2:58 PM (in response to wdfink)So what is your reason to start an external process?
I have to run some "untrusted" Java code (uploaded by users). I don't want my JBoss application will have a chance to be affected from this code, so I'm starting new process which runs this code in another JVM (with appropriate SecurityManager and memory allocation etc.).
-
5. Re: Running external processes from JBoss
laumarot May 17, 2013 3:47 AM (in response to evyatarc)Facing same problem two years after. any clue for launching from jboss an external java class that can't be shipped in war/ear because of library compliance issue ?
-
6. Re: Running external processes from JBoss
evyatarc May 18, 2013 3:26 PM (in response to laumarot)If you need to run external process from your JBoss process (or any other Java process), possible solution that solves the memory duplication problem is to use Java service wrapper. The wrapper is a small process that starts your JVM, and let you start external process by forking the small wrapper process rather than the huge JBoss process.
There are several Java wrapper tools, for example:
http://wrapper.tanukisoftware.com - Tanuki Java Service Wrapper (commercial)
http://yajsw.sourceforge.net/ - YAJSW (free)
There are other benefits by using a wrapper, like detecting GC problems, deadlocks, exceptions and other runtime problems.
-
7. Re: Running external processes from JBoss
laumarot May 19, 2013 10:48 AM (in response to evyatarc)That sounds very nice to me !
I've a got a java API that makes JBoss crash at startup. As a similar C API exists I hope I could use it through java warapper. Do you think YAJSW would make the trick in that case ?