2 Replies Latest reply on May 31, 2011 3:14 PM by Purvi Maru

    Issue with Runtime.getRuntime().exec()

    Purvi Maru Newbie



      We are facing issues with Runtime.getRuntime().exec() function in the application. The application resides on Solaris 10 and using Jboss 4.0.4.GA.


      Some of the application functionality uses the Runtime.getRuntime().exec() function to execute a .sh script in unix. Sometime this process hangs and so the functionality hangs and occasionally Jboss crashes. Once we restart the Jboss application, everything is back to normal.


      Also, when the application hangs, we tried executing the Runtime.getRuntime().exec() from Java program via command line and it works fine but it doesnt work when we try to execute the same code within Jboss.


      We checked the basic memory parameters from the JMX-console at the time when Runtime.getRuntime().exec() hangs and it looks fine.


      I think that there is issue with some memory setting, can you help me identify which parameter should I look at? Also, any recommendations are welcomed.



      Purvi Maru

        • 1. Re: Issue with Runtime.getRuntime().exec()
          Mark Paluch Master

          Hi Purvi,

          can you post some data to JVM crash? In Java 1.6.0_20 I hade once a problem, that JBoss crashed (within native code) when it ran in a specific Database-Query. The problem was, that an explicit stack size was set and JVM crashed instead of throwing StackOverflowException. Try a more direct call instead of nested EJB calls (if applicable). When exec() hangs, is your shell-script done or does it hang within the shell-script?


          Best regards,


          • 2. Re: Issue with Runtime.getRuntime().exec()
            Purvi Maru Newbie

            The script does not complete, the code hangs on the line "process = Runtime.getRuntime().exec(command, null, workingDir);"

            The command is alchemy to generate low res rendtions.


            We did not see any StackOverflowExceptions in the logs.


            When the number of users requesting renditions increase [which tiggers the Runtime.getRuntime().exec code to be called]

            then we are unable to execute Runtime.getRuntime().exec and the code hangs at that line or jboss crashes.


            We tried directly executing this code from within jboss when we reached the hung state where only Runtime.getRuntime().exec would hang up but the rest of the application ran fine. however if we run the Runtime.getRuntime().exec form a java program via command line it ran fine.


            I think it has to do with some memory settings with jboss which may explain why the same code works fine outside jboss when jboss or the code reaches that hung state.