3 Replies Latest reply on May 31, 2013 8:48 PM by mikelvadillo

    Init script of jboss 4.2.3 GA - jdk6 for Debian 7

    mikelvadillo

      Hi all, ultra noob mega newbie here.

       

      I'm an student of Informatics Ingeniering in the university of Basque Country, Spain.

       

      For my last year project i'm trying to make work a server with OpenACS (http://sourceforge.net/projects/openacs/) in a Debian 7 distribution with many routers. This opensource web service goes over Jboss (author recomends 4.2.x versions) and at least i have managed to configure almost all. I'm glad because is my first contact with this and it is very interesting.

       

      My only problem is to use a good init script to use with Debian 7. I have composed one, using several i have found over internet and mixing them. Finally it works, it seems to my noob eyes, fine. This is the script:

       

       

      #!/bin/sh

      ### BEGIN INIT INFO

      # Provides: jboss

      # Required-Start: $local_fs $remote_fs $network $syslog

      # Required-Stop: $local_fs $remote_fs $network $syslog

      # Default-Start: 2 3 4 5

      # Default-Stop: 0 1 6

      # Short-Description: Start/Stop JBoss AS v7.0.0

      ### END INIT INFO

       

       

      JBOSS_HOME=/opt/jboss

       

      JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-i386

       

      #JBOSS_BIND_ADDR="-b 192.168.1.205"

       

      #configuration to use, usually one of 'minimal', 'default', 'all'

      #JBOSS_CONF=${JBOSS_CONF:-"default"}

       

      export JAVA_HOME

      export JBOSS_HOME

       

       

      EXEC=${JBOSS_HOME}/bin/run.sh

      #JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh -b 192.168.1.205"}

      #define the script to use to start jboss

      #JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh -c $JBOSS_CONF"}

       

      do_start(){   

              start-stop-daemon --start --chuid jboss --user jboss --name jboss -b --exec ${EXEC}

          }

       

      do_stop(){

              start-stop-daemon --stop -u jboss

              rm -f ${PIDFILE}

      }

       

      case "$1" in

          start)

              echo "Starting JBoss 4.2.3"

          do_start

          ;;

          stop)

              echo "Stopping JBoss 4.2.3"

          do_stop

          ;;

          restart)

          echo "Restarting JBoss 4.2.3"

          do_stop

          sleep 20

          do_start

          ;;

          *)

              echo "Usage: /etc/init.d/jboss4.2.3 {start|stop|restart}"

              exit 1

          ;;

      esac

       

       

      My problem is the ip binding. Untill now i have been starting Jboss through console using:

       

      cd /opt/jboss/bin

      ./run.sh -b 192.168.1.205

       

      but now what i get with this script is the web only working in localhost as URL.

       

      I have read many articles in the internet about this but i can't make it work. As you can see in the script, there are several tryes i have done in commented lines but none of them have worked well.

       

      I have even tryed to add this two things (not at the same time) in the /opt/jboss/bin/run.conf file:

       

      -Dbind.address=192.168.1.205

      -Djgroups.bind_addr=192.168.1.205

       

      But it's not worth it.

       

      Any ideas?

       

      Perhaps, due to my poor english, you should have questions about what i have done or how bad i have explained it....feel free to ask.

       

      Thanks in advance.

        • 1. Re: Init script of jboss 4.2.3 GA - jdk6 for Debian 7
          jaikiran

          Mikel, welcome to the forums!

           

          Does this work:

           

          ...
          JBOSS_BIND_ADDR=-b 192.168.1.205
          ... 
          EXEC=${JBOSS_HOME}/bin/run.sh ${JBOSS_BIND_ADDR}
          ... 
          do_start(){    
                  start-stop-daemon --start --chuid jboss --user jboss --name jboss  --exec ${EXEC}
              }
          
          • 2. Re: Init script of jboss 4.2.3 GA - jdk6 for Debian 7
            mikelvadillo
            Thankyou so much for your interest......No it doesn`t work.
            root@ServerACS:~# /etc/init.d/jboss4.2.3 start
            /etc/init.d/jboss4.2.3: 16: /etc/init.d/jboss4.2.3: 192.168.1.205: not found
            Starting JBoss 4.2.3
            The server starts but only in localhost.
            But....
            root@ServerACS:~# ifconfig
            eth0 Link encap:Ethernet HWaddr 00:0c:29:f8:c5:c0
            inet addr:192.168.1.205 Bcast:192.168.1.255 Mask:255.255.255.0
            inet6 addr: fe80::20c:29ff:fef8:c5c0/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
            RX packets:20013 errors:0 dropped:0 overruns:0 frame:0
            TX packets:11000 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000
            RX bytes:28203752 (26.8 MiB) TX bytes:881200 (860.5 KiB)
            Interrupt:19 Base address:0x2024
            lo Link encap:Local Loopback
            inet addr:127.0.0.1 Mask:255.0.0.0
            inet6 addr: ::1/128 Scope:Host
            UP LOOPBACK RUNNING MTU:16436 Metric:1
            RX packets:736 errors:0 dropped:0 overruns:0 frame:0
            TX packets:736 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:0
            RX bytes:255437 (249.4 KiB) TX bytes:255437 (249.4 KiB)
            Thank you again.
            • 3. Re: Init script of jboss 4.2.3 GA - jdk6 for Debian 7
              mikelvadillo

              Hi everyone....

               

              At the end i found the problem in the man pages of start-stop-daemon:

               

              −S,−−start [−−]arguments

               

              Check for the existence of a specified process. If such a process exists,start−stop−daemon does nothing, and exits with error status 1 (0 if −−oknodo is specified). If such a process does not exist, it starts an instance, using either the executable specified by−−exec or, if specified, by−−startas. Any arguments given after−− on the command line are passed unmodified to the program being started.

               

              so .......

               

              ...
              PARAMS="-b 192.168.1.205"
              DAEMON=${JBOSS_HOME}/bin/run.sh
              ...
              do_start(){   
                      start-stop-daemon --start --chuid jboss --user jboss --name jboss  --exec ${DAEMON} -- ${PARAMS}
                  }
              ....

               

              I was missing the -- before the parametres.

               

              Thanks all anyway......

               

              P.D.: the complete final script with a sleep modification too:

               

              #!/bin/sh
              ### BEGIN INIT INFO
              # Provides: jboss
              # Required-Start: $local_fs $remote_fs $network $syslog
              # Required-Stop: $local_fs $remote_fs $network $syslog
              # Default-Start: 2 3 4 5
              # Default-Stop: 0 1 6
              # Short-Description: Start/Stop JBoss AS v7.0.0
              ### END INIT INFO


              JBOSS_HOME=/opt/jboss

              JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-i386

               

              export JAVA_HOME
              export JBOSS_HOME

               

              PARAMS="-b 192.168.1.205"
              DAEMON=${JBOSS_HOME}/bin/run.sh

               

              do_start(){
                start-stop-daemon --start --chuid jboss --user jboss --name jboss -b --exec ${DAEMON} -- ${PARAMS}
              }

               

              do_stop(){
                start-stop-daemon --stop -u jboss
                rm -f ${PIDFILE}
              }

               

              case "$1" in
                  start)
                      echo "Starting JBoss 4.2.3"
              do_start
                  ;;
                  stop)
                      echo "Stopping JBoss 4.2.3"
              do_stop
                  ;;
                  restart)
              echo "Restarting JBoss 4.2.3"
              do_stop
              sleep 30
              do_start
                  ;;
                  *)
                      echo "Usage: /etc/init.d/jboss4.2.3 {start|stop|restart}"
                      exit 1
                  ;;
              esac