8 Replies Latest reply on Jun 10, 2013 1:26 AM by Nicklas Karlsson

    Configure jboss 7 as a service fedora 14

    Jerson Viveros Newbie

      Hello!

       

      I need help.

       

      I want to public a software on internet throught a Virtual Dedicated Server of godaddy with fedora 14.

       

      I have some questions:

       

      1- How can I configure my jboss 7 as a service on fedora 14?

      2- How can I run the service with a linux user diferent of root?

      3- How can I configure the linux to start the service when the server is restart?

      4- Which is the advantage of runing  jboss 7 as a service?

      5- Which is the advantage of runing  jboss 7 with a user diferent of root?

       

      Thanks in advance!

       

      Jerson

        • 1. Re: Configure jboss 7 as a service fedora 14
          Nicklas Karlsson Master

          https://community.jboss.org/wiki/HowToInstallJBossAS7AsALinuxService

           

          1) See article

          2) Set JBOSS_USER in the startup scripts or env

          3) See article

          4) Starts up at server boot

          5) Possible exploits can't escape user space. Running in root is generally considered a Bad Idea on unixes.

          • 2. Re: Configure jboss 7 as a service fedora 14
            Jerson Viveros Newbie

            Thank you very much for your answer!

            I've already made the configuration like in the article, but I don't know why the service command doesn't work for me, this is my configuration:

             

             

            [root@ip-50-63-43-350 jerviver31]# ls /etc/init.d/

            crond      dc_server  halt   ip6tables  jbossas7  modules_dep  named       netfs    nmb   postgresql-9.1  reboot   rsyslog    sendmail  smb    snmptrapd  udev-post  xinetd

            dc_client  functions  httpd  iptables   killall   mysqld       netconsole  network  nscd  rdisc           rpcbind  saslauthd  single    snmpd  sshd       vzquota

            [root@ip-50-63-43-350 jerviver31]# ls /etc/rc.d/init.d/

            crond      dc_server  halt   ip6tables  jbossas7  modules_dep  named       netfs    nmb   postgresql-9.1  reboot   rsyslog    sendmail  smb    snmptrapd  udev-post  xinetd

            dc_client  functions  httpd  iptables   killall   mysqld       netconsole  network  nscd  rdisc           rpcbind  saslauthd  single    snmpd  sshd       vzquota

            [root@ip-50-63-43-350 jerviver31]# chkconfig --list

            ...

            iptables       0:off 1:off 2:on 3:on 4:on 5:on 6:off

            jbossas7       0:off 1:off 2:off 3:on 4:off 5:off 6:off

            ....

            [root@ip-50-63-43-350 jerviver31]# service jbossas7 start

            env: /etc/init.d/jbossas7: No such file or directory

            [root@ip-50-63-43-350 jerviver31]#

             

             

            And the /etc/rc.d/init.d/jbossas7

             

             

            #!/bin/bash### BEGIN INIT INFO

            # Provides:          jbossas7

            # 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 7

            ### END INIT INFO

            # chkconfig: 35 92 1

             

             

            ## Include some script files in order to set and export environmental variables

            ## as well as add the appropriate executables to $PATH.

            [ -r /etc/profile.d/java.sh ] && . /etc/profile.d/java.sh

            [ -r /etc/profile.d/jboss.sh ] && . /etc/profile.d/jboss.sh

             

             

            JBOSS_HOME=/home/jerviver31/server/jboss-as-7.1.1.Final/

             

             

            AS7_OPTS="$AS7_OPTS -Dorg.apache.tomcat.util.http.ServerCookie.ALLOW_HTTP_SEPARATORS_IN_V0=true"   ## See AS7-1625

            AS7_OPTS="$AS7_OPTS -Djboss.bind.address.management=50.63.43.350"

            AS7_OPTS="$AS7_OPTS -Djboss.bind.address=50.63.43.350"

             

             

            case "$1" in

                start)

                    echo "Starting JBoss AS 7..."

                    sudo -u jboss sh ${JBOSS_HOME}/bin/standalone.sh $AS7_OPTS           ##  If running as user "jboss"

                    #start-stop-daemon --start --quiet --background --chuid jboss --exec ${JBOSS_HOME}/bin/standalone.sh $AS7_OPTS   ## Ubuntu

                    #${JBOSS_HOME}/bin/standalone.sh $AS7_OPTS &

                ;;

                stop)

                    echo "Stopping JBoss AS 7..."

                    sudo -u jboss sh ${JBOSS_HOME}/bin/jboss-admin.sh --connect command=:shutdown            ##  If running as user "jboss"

                    #start-stop-daemon --start --quiet --background --chuid jboss --exec ${JBOSS_HOME}/bin/jboss-admin.sh -- --connect command=:shutdown     ## Ubuntu

                    #${JBOSS_HOME}/bin/jboss-cli.sh --connect command=:shutdown

                ;;

                *)

                    echo "Usage: /etc/init.d/jbossas7 {start|stop}"; exit 1;

                ;;

            esac

             

             

            exit 0

            • 3. Re: Configure jboss 7 as a service fedora 14
              Wolf-Dieter Fink Master

              There is a difference in the path "rc.d":

               

              [root@ip-50-63-43-350 jerviver31]# service jbossas7 start

              env: /etc/init.d/jbossas7: No such file or directory

              [root@ip-50-63-43-350 jerviver31]#

               

               

              And the /etc/rc.d/init.d/jbossas7

              • 4. Re: Configure jboss 7 as a service fedora 14
                Jerson Viveros Newbie

                Thanks for the answer! in the both paths /etc/init.d and /etc/rc.d/init.d  is the jbossas7 script. I don know how Fedora works, but when you create a file in /etc/rc.d/init.d, it automatically create a link to /etc/init.d.

                 

                The real problem was:

                 

                #!/bin/bash### BEGIN INIT INFO

                # Provides:          jbossas7

                 

                 

                Have to be:

                #!/bin/bash

                ### BEGIN INIT INFO

                # Provides:          jbossas7

                 

                A small detail, but very important.

                • 5. Re: Configure jboss 7 as a service fedora 14
                  Jerson Viveros Newbie

                  Now my problem is this:

                   

                  # service jbossas7 start

                  Starting JBoss AS 7...

                  ========================================================================

                    JBoss Bootstrap Environment

                    JBOSS_HOME: /home/jboss/server/jboss-as-7.1.1.Final

                    JAVA: java

                    JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.server.default.config=standalone.xml

                  =========================================================================

                  /home/jboss/server/jboss-as-7.1.1.Final/bin/standalone.sh: line 178: java: command not found

                  #

                   

                  I don't know why because I configured my enviorement variable $PATH

                   

                  # java -version

                  java version "1.7.0_21"

                  Java(TM) SE Runtime Environment (build 1.7.0_21-b11)

                  Java HotSpot(TM) Client VM (build 23.21-b01, mixed mode)

                   

                   

                  Is weird because when I run the service with: #sh $JBOSS_HOME/bin/standalone.sh  like jboss user, it starts without any problem... but with the command service have the problem of the java: command not found.

                   

                  Someone that have any idea?

                  • 6. Re: Configure jboss 7 as a service fedora 14
                    Jerson Viveros Newbie

                    The problem is sudo

                    But I don't know why.... when I use sudo to start the service... it throw java: command not found

                     

                    How configure the $PATH for sudo permanently?

                    • 7. Re: Configure jboss 7 as a service fedora 14
                      Jerson Viveros Newbie

                      I've got to use:

                      $JBOSS_HOME/bin/init.d/jboss-as-standalone.sh

                       

                      and change this line:

                      # chkconfig: 3 80 20

                       

                      and add, the JBOSS_USER with:

                      JBOSS_USER=jboss

                      export JBOSS_USER

                       

                       

                      Now is running well, but I have a last problem.

                       

                      It throws an Exception because I want to use the 80 port and I running the server with a user differente than root.

                       

                      I try to use the iptables to redirect to 8080 port but I get this error:

                       

                      # iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080

                      FATAL: Module ip_tables not found.

                      iptables v1.4.9: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)

                      Perhaps iptables or your kernel needs to be upgraded.

                       

                       

                      What can I make to use the 80 port and run the server as jboss user? (Considering the problem with the iptables)