6 Replies Latest reply on Jun 13, 2013 4:21 PM by Christopher Slagel

    Running numerous instances of JBoss as a service

    Christopher Slagel Newbie

      OK, I'm in serious need of some help. 

       

      We're currently using Firedaemon to run JBoss as a service on our servers.  Each server hosts numerous instances. 

       

      The configuration for each instance currently looks like this:

       

      Screen Shot 2013-06-12 at 3.27.18 PM.png

       

      Where the service kicks off the run.bat and passes the correct parameters to the bat file.  Bam, easy.

       

      This is all well and dandy, but doing it this way does not control the java process.  This has caused some issues as they sometimes go rogue after the service is stopped.  Firedaemon supplies a tutorial for running a JBoss instance as a service that controls the java process itself here (http://forums.firedaemon.com/howtos/jboss-j2ee.64/) but the problem is this doesn't allow for us to run numerous instances.  As you can tell from the config using their tutorial:

       

      Screen Shot 2013-06-12 at 3.32.35 PM.pngScreen Shot 2013-06-12 at 3.32.46 PM.png

      It basically skips over the run.bat file entirely and kicks everything off manually.

       

      The main issue is I no longer have a way to pass the -c and -b options to run.bat.  I'm sure there's a fairly simple way to add in these parameters doing it this way, I just don't have a solid enough understanding to do so.

       

      Any input would be greatly appretiated!  Thanks!

        • 1. Re: Running numerous instances of JBoss as a service
          Christopher Slagel Newbie

          OK so after analyzing the run.bat file I've found that the options get passed at the end of the

           

          %JAVA_OPTS% "-Djava.endorsed.dirs=%JBOSS_ENDORSED_DIRS%" -classpath "%JBOSS_RUNPATH%" org.jboss.Main

           

          sting. 

           

          So that now reads

           

          %JAVA_OPTS% "-Djava.endorsed.dirs=%JBOSS_ENDORSED_DIRS%" -classpath "%JBOSS_RUNPATH%" org.jboss.Main -c "name" -b 10.1.3.129

           

          ...yet still no luck.

          • 2. Re: Running numerous instances of JBoss as a service
            erasmo2 marciano2 Master

            What's your problem?

             

            Have you difficult with parameter of Jboss -c -b etc...

            • 3. Re: Running numerous instances of JBoss as a service
              Wolf-Dieter Fink Master

              Could you start the first server without issues?

              What error messages do you see in the logfiles?

              Do you use virtual IP addresses or have several NIC? You need to separate the instances by IP or by using port-binding to ensure that all instances are able to listen on a unique port

              • 4. Re: Running numerous instances of JBoss as a service
                Christopher Slagel Newbie

                The issue is getting the parameters to pass so that it fires up the correct instance.  According to the logs it looks like I'm not passing the parameters correctly:

                 

                Exception in thread "main" Unrecognized option: -c

                Unrecognized option: -c

                Unrecognized option: -c

                Unrecognized option: -c

                Unrecognized option: -c

                Unrecognized option: -c

                Unrecognized option: -c

                java.lang.NoClassDefFoundError: org/jboss/Main

                 

                Although I thought I was doing it in the same way that run.bat does.

                • 5. Re: Running numerous instances of JBoss as a service
                  Christopher Slagel Newbie

                  They start up, java starts and everything, it's just not starting the instance that I want it to start.  Again, the parameters seem to be the issue here.

                   

                  run.bat looks like this:

                   

                  @echo off

                  rem -------------------------------------------------------------------------

                  rem JBoss Bootstrap Script for Win32

                  rem -------------------------------------------------------------------------

                   

                   

                  rem $Id: run.bat 63249 2007-05-30 13:20:25Z dimitris@jboss.org $

                   

                   

                  @if not "%ECHO%" == ""  echo %ECHO%

                  @if "%OS%" == "Windows_NT"  setlocal

                   

                   

                  set DIRNAME=.\

                  if "%OS%" == "Windows_NT" set DIRNAME=%~dp0%

                  set PROGNAME=run.bat

                  if "%OS%" == "Windows_NT" set PROGNAME=%~nx0%

                   

                   

                  pushd %DIRNAME%..

                  set JBOSS_HOME=%CD%

                  popd

                   

                   

                  REM Add bin/native to the PATH if present

                  if exist "%JBOSS_HOME%\bin\native" set PATH=%JBOSS_HOME%\bin\native;%PATH%

                  if exist "%JBOSS_HOME%\bin\native" set JAVA_OPTS=%JAVA_OPTS% -Djava.library.path="%PATH%"

                   

                   

                  rem Read all command line arguments

                   

                   

                  REM

                  REM The %ARGS% env variable commented out in favor of using %* to include

                  REM all args in java command line. See bug #840239. [jpl]

                  REM

                  REM set ARGS=

                  REM :loop

                  REM if [%1] == [] goto endloop

                  REM         set ARGS=%ARGS% %1

                  REM         shift

                  REM         goto loop

                  REM :endloop

                   

                   

                  rem Find run.jar, or we can't continue

                   

                   

                  set RUNJAR=%JBOSS_HOME%\bin\run.jar

                  if exist "%RUNJAR%" goto FOUND_RUN_JAR

                  echo Could not locate %RUNJAR%. Please check that you are in the

                  echo bin directory when running this script.

                  goto END

                   

                   

                  :FOUND_RUN_JAR

                  set JAVA_HOME=E:\jdk1.5.0_12

                   

                   

                  if not "%JAVA_HOME%" == "" goto ADD_TOOLS

                   

                   

                  set JAVA=java

                   

                   

                  echo JAVA_HOME is not set.  Unexpected results may occur.

                  echo Set JAVA_HOME to the directory of your local JDK to avoid this message.

                  goto SKIP_TOOLS

                   

                   

                  :ADD_TOOLS

                   

                   

                  set JAVA=%JAVA_HOME%\bin\java

                   

                   

                  rem A full JDK with toos.jar is not required anymore since jboss web packages

                  rem the eclipse jdt compiler and javassist has its own internal compiler.

                  if not exist "%JAVA_HOME%\lib\tools.jar" goto SKIP_TOOLS

                   

                   

                  rem If exists, point to the JDK javac compiler in case the user wants to

                  rem later override the eclipse jdt compiler for compiling JSP pages.

                  set JAVAC_JAR=%JAVA_HOME%\lib\tools.jar

                   

                   

                  :SKIP_TOOLS

                   

                   

                  rem If JBOSS_CLASSPATH or JAVAC_JAR is empty, don't include it, as this will

                  rem result in including the local directory in the classpath, which makes

                  rem error tracking harder.

                  if not "%JAVAC_JAR%" == "" set RUNJAR=%JAVAC_JAR%;%RUNJAR%

                  if "%JBOSS_CLASSPATH%" == "" set RUN_CLASSPATH=%RUNJAR%

                  if "%RUN_CLASSPATH%" == "" set RUN_CLASSPATH=%JBOSS_CLASSPATH%;%RUNJAR%

                   

                   

                  set JBOSS_CLASSPATH=%RUN_CLASSPATH%

                   

                   

                  rem Setup JBoss specific properties

                  set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name=%PROGNAME%

                   

                   

                  rem Add -server to the JVM options, if supported

                  "%JAVA%" -version 2>&1 | findstr /I hotspot > nul

                  if not errorlevel == 1 (set JAVA_OPTS=%JAVA_OPTS% -server)

                   

                   

                  rem JVM memory allocation pool parameters. Modify as appropriate.

                  set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx1024m

                   

                   

                  rem With Sun JVMs reduce the RMI GCs to once per hour

                  set JAVA_OPTS=%JAVA_OPTS% -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000

                   

                   

                  rem JPDA options. Uncomment and modify as appropriate to enable remote debugging.

                  rem set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y %JAVA_OPTS%

                   

                   

                  rem Setup the java endorsed dirs

                  set JBOSS_ENDORSED_DIRS=%JBOSS_HOME%\lib\endorsed

                   

                   

                  echo ===============================================================================

                  echo.

                  echo   JBoss Bootstrap Environment

                  echo.

                  echo   JBOSS_HOME: %JBOSS_HOME%

                  echo.

                  echo   JAVA: %JAVA%

                  echo.

                  echo   JAVA_OPTS: %JAVA_OPTS%

                  echo.

                  echo   CLASSPATH: %JBOSS_CLASSPATH%

                  echo.

                  echo ===============================================================================

                  echo.

                   

                   

                  :RESTART

                  "%JAVA%" %JAVA_OPTS% "-Djava.endorsed.dirs=%JBOSS_ENDORSED_DIRS%" -classpath "%JBOSS_CLASSPATH%" org.jboss.Main %*

                  if ERRORLEVEL 10 goto RESTART

                   

                   

                  :END

                  if "%NOPAUSE%" == "" pause

                   

                   

                  :END_NO_PAUSE

                   

                  So it looked like it was passing the arguments after org.jboss.Main, so that's where I put them.  but according to the logs it does not like that.

                  • 6. Re: Running numerous instances of JBoss as a service
                    Christopher Slagel Newbie

                    New update I think I found the problem:

                     

                    Thu Jun 13 12:36:50 2013 [0xa68]: Env variable: JBOSS_SHUTDOWNPATH="%SHUTDOWNJAR%;%JBOSS_HOME%\client\jbossall-client.jar"

                    Thu Jun 13 12:36:50 2013 [0xa68]: Env variable: JBOSS_RUNPATH="%JAVAC_JAR%;%RUNJAR%"

                    Thu Jun 13 12:36:50 2013 [0xa68]: Env variable: JBOSS_ENDORSED_DIRS="%JBOSS_HOME%\lib\endorsed"

                    Thu Jun 13 12:36:50 2013 [0xa68]: Env variable: JAVA_OPTS="-Xrs -Xms128m -Xmx512m"

                    Thu Jun 13 12:36:50 2013 [0xa68]: Env variable: JAVAC_JAR="%JAVA_HOME%\lib\tools.jar"

                    Thu Jun 13 12:36:50 2013 [0xa68]: Env variable: SHUTDOWNJAR="%JBOSS_HOME%\bin\shutdown.jar"

                    Thu Jun 13 12:36:50 2013 [0xa68]: Env variable: JAVA="%JAVA_HOME%\bin\java.exe"

                    Thu Jun 13 12:36:50 2013 [0xa68]: Env variable: RUNJAR="%JBOSS_HOME%\bin\run.jar"

                    Thu Jun 13 12:36:50 2013 [0xa68]: Env variable: JBOSS_HOME="E:\jboss-4.2.1.GA"

                    Thu Jun 13 12:36:50 2013 [0xa68]: Env variable: JAVA_HOME="e:\jdk1.5.0_12\bin\java"

                    Thu Jun 13 12:36:50 2013 [0xa68]: Starting worker thread

                    Thu Jun 13 12:36:50 2013 [0xa68]: Starting monitoring thread

                    Thu Jun 13 12:36:50 2013 [0xd7c]: Starting WorkerSubProcess

                    Thu Jun 13 12:36:50 2013 [0xa68]: Ckpt: 3 State: Start-pending [2]

                    Thu Jun 13 12:36:50 2013 [0x178]: Starting MonitorSubProcess

                    Thu Jun 13 12:36:50 2013 [0xa68]: Service initialization complete.

                    Thu Jun 13 12:36:50 2013 [0xa68]: Service 'jas': Event no. 1 [0x1]  528

                    Thu Jun 13 12:36:50 2013 [0xd7c]: Service 'jas': Event no. 17 [0x11] 

                    Thu Jun 13 12:36:50 2013 [0xa68]: Ckpt: 0 State: Running [4]

                    Thu Jun 13 12:36:50 2013 [0xa68]: Waiting on hSyncEvent.

                    Thu Jun 13 12:36:50 2013 [0xd7c]: Redirecting stdout to 'E:\jboss-4.2.1.GA\server\java\log\server.log'

                    Thu Jun 13 12:36:50 2013 [0xd7c]: Redirecting stderr to stdout

                    Thu Jun 13 12:36:50 2013 [0xd7c]: Launching process 'E:\jdk1.5.0_12\bin\javaw.exe -Xrs -Xms128m -Xmx512m "-Djava.endorsed.dirs=%JBOSS_HOME%\lib\endorsed" -classpath "%JAVAC_JAR%;%RUNJAR%" org.jboss.Main'

                    Thu Jun 13 12:36:50 2013 [0xd7c]: Starting the process Non Interactively, flags = 0x00000020

                    Thu Jun 13 12:36:50 2013 [0xd7c]: CreateProcess() call returned 1

                    Thu Jun 13 12:36:50 2013 [0xd7c]:     Process Id: 2688

                    Thu Jun 13 12:36:50 2013 [0xd7c]: Service 'jas': Event no. 18 [0x12]  E:\jdk1.5.0_12\bin\javaw.exe -Xrs -Xms128m -Xmx512m "-Djava.endorsed.dirs=%JBOSS_HOME%\lib\endorsed" -classpath "%JAVAC_JAR%;%RUNJAR%" org.jboss.Main

                     

                    If you look towards the bottom when it calls:

                     

                    %JAVA_OPTS% "-Djava.endorsed.dirs=%JBOSS_ENDORSED_DIRS%" -classpath "%JBOSS_RUNPATH%" org.jboss.Main

                     

                    some of the variables aren't getting filled with their values...?  Why would that be?