7 Replies Latest reply on May 19, 2013 10:48 AM by laumarot

    Running external processes from JBoss

    evyatarc

      I have to execute external process from EJB deployed on JBoss in Linux machine.

      What is the best way to do it, avoiding memory duplication problem?

       

      Thanks!

        • 1. Running external processes from JBoss
          wdfink

          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

            I think Mladen had writen some native utilities to let you do all sorts of this kind of things. I'll ping him...

            1 of 1 people found this helpful
            • 3. Running external processes from JBoss
              mladen.turk

              Yep, 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.

              1 of 1 people found this helpful
              • 4. Running external processes from JBoss
                evyatarc

                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

                  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

                    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

                      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 ?