8 Replies Latest reply on Sep 30, 2009 1:39 PM by Gene Ellis

    JBOSS runs as a service, but will not autostart

    Gene Ellis Newbie

      I can successfully get JBOSS to start by typing service jboss start from the command line, but cannot get it to auto start as a service.

      I believe I have done everything necessary:
      1) Placed chkconfig: 2345 80 20 in my start script
      2) Executed chkconfig --list to make sure it has been added
      3) Checked the server run level (3) to make sure I have the right values for chkconfig
      4) Executed ntsysv to make sure there is an "*" in the JBOSS box (there is)
      5) Manually looked in the rc3.d folder to make sure a symlink is there.
      6) Have manually run the commands in the startup script (from command line) to make sure they properly start the JBOSS server (they do)

      Whew! So when I reboot my server, JBOSS still doesn't start automatically. Is there some simple step I am missing? Thanks!

        • 1. Re: JBOSS runs as a service, but will not autostart
          Peter Johnson Master

          What account are you using to run the service? Does that account have full rights to the jboss-xxx directory and its subdirectories?

          What version of JBoss AS and which OS?

          • 2. Re: JBOSS runs as a service, but will not autostart
            Gene Ellis Newbie

            Thank you for your reply.

            I am using root when I manually start the service from command line. I am also using the command sudo -u root /path/to/jboss/bin/run.sh -b 0.0.0.0 in side the JBOSS (service) file.
            Jboss Version: 4.2.2.GA
            OS is CentOS

            • 3. Re: JBOSS runs as a service, but will not autostart
              Peter Johnson Master

              Are you redirecting stdout/stderr when invoking run.sh to a file? Does the file give any hints? Is there anything in the log files?

              • 4. Re: JBOSS runs as a service, but will not autostart
                Gene Ellis Newbie

                Hey Peter,

                No I am not redirecting stout/stderr if I am understanding you correctly. What is the exact procedure for examining the logs?

                Thanks again.

                • 5. Re: JBOSS runs as a service, but will not autostart
                  Peter Johnson Master

                  So after you changed the script to redirect stdout/stderr to a file (hint, hint), what did you find out?

                  I probably should have been more specific and stated "JBoss AS log files"

                  • 6. Re: JBOSS runs as a service, but will not autostart
                    Gene Ellis Newbie

                    I will let you know. I know a bit about Unix, but there are parts I am still learning. I don't know how to change that, but I will google it. Also, keep in mind, this script runs fine when I execute it from command line. Even when I make it a service. The only thing not happening is when I restart my server, the service isn't automatically started.

                    • 7. Re: JBOSS runs as a service, but will not autostart
                      Peter Johnson Master

                      Yes, I understand all that, but "weird" things happen when services start automatically at startup. What I am suspecting is that the OS does attempt to start the service, but it is crashing for some reason. I imagine there is an OS log file somewhere that might give some clues on the issue, but I would not know offhand. And even if I knew where that log was on Ubuntu , such knowledge might not help you on CentOS. So the best alternative is to have the script "echo" so info.

                      If you are using one of the jboss_init_*.sh scripts, then you will see this:

                      JBOSS_CONSOLE=${JBOSS_CONSOLE:-"/dev/null"}
                      . . .
                      eval $JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &


                      in which case all you have to do is change the /dev/null to something a little more permanent ;-) Or set JBOSS_CONSOLE earlier script - there are some 'if' statements earlier in the script that ensure the files is accessible, so set it before those statements. And of course test manually first.

                      • 8. Re: JBOSS runs as a service, but will not autostart
                        Gene Ellis Newbie

                        Ok I see. I will make this changes tonight and let you know what I find. I am not using that exact script, but a simplified version. Basically this one:

                        #! /bin/sh
                        
                        
                        start(){
                         echo "Starting jboss.."
                        
                         # If using an SELinux system such as RHEL 4, use the command below
                         # instead of the "su":
                         # eval "runuser - jboss -c '/opt/jboss/current/bin/run.sh > /dev/null 2> /dev/null &'
                         # if the 'su -l ...' command fails (the -l flag is not recognized by my su cmd) try:
                         # sudo -u jboss /opt/jboss/bin/run.sh > /dev/null 2> /dev/null &
                         su -l jboss -c '/opt/jboss/current/bin/run.sh > /dev/null 2> /dev/null &'
                        }
                        
                        stop(){
                         echo "Stopping jboss.."
                        
                         # If using an SELinux system such as RHEL 4, use the command below
                         # instead of the "su":
                         # eval "runuser - jboss -c '/opt/jboss/current/bin/shutdown.sh -S &'
                         # if the 'su -l ...' command fails try:
                         # sudo -u jboss /opt/jboss/bin/shutdown.sh -S &
                         su -l jboss -c '/opt/jboss/current/bin/shutdown.sh -S &'
                        }
                        
                        restart(){
                         stop
                        # give stuff some time to stop before we restart
                         sleep 60
                        # protect against any services that can't stop before we restart (warning this kills all Java instances running as 'jboss' user)
                         su -l jboss -c 'killall java'
                        # if the 'su -l ...' command fails try:
                         # sudo -u jboss killall java
                         start
                        }
                        
                        
                        
                        
                        case "$1" in
                         start)
                         start
                         ;;
                         stop)
                         stop
                         ;;
                         restart)
                         restart
                         ;;
                         *)
                         echo "Usage: jboss {start|stop|restart}"
                         exit 1
                        esac
                        
                        exit 0


                        Thanks so much for your help!