6 Replies Latest reply on Sep 13, 2012 4:33 PM by Ranga Raju Venkata Surya

    java.io.IOException: Cannot run program error=13

    Ranga Raju Venkata Surya Newbie

      When running the jboss domain startup command to start/stop jboss AS 711 my developer is getting the below error. jboss is running as user "jboss". Since we do not give full access to jboss userid to developers, we give them access to the start stop scripts and have them execute as shown below through sudo command. This is Red Hat Linux host.

       

      [mkumar@jasper1 ~]$ sudo -u jboss /opt/jboss/jboss_as_711/bin/init.d/jboss-as-domain.sh start

      Starting jboss-as: Current User is jboss

      1. java.io.IOException: Cannot run program "/java/jdk7/bin/java" (in directory "/home/mkumar"): error=13, Permission denied

      at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)

      at org.jboss.as.process.ManagedProcess.doStart(ManagedProcess.java:192)

      at org.jboss.as.process.ManagedProcess.start(ManagedProcess.java:148)

      at org.jboss.as.process.ProcessController.startProcess(ProcessController.java:129)

      at org.jboss.as.process.Main.start(Main.java:214)

      at org.jboss.as.process.Main.main(Main.java:72)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

       

      Permissions on the java executable is:  (everyone have execute privileges)

       

      -rwxrwxr-x 1 jboss jboss 7750 Aug  9 20:07 /java/jdk7/bin/java

       

      The user's .bash_profile is:

       

      ##---------------------------------------------------------------------------------------

      cat /home/mkumar/.bash_profile

      # .bash_profile

       

      # Get the aliases and functions

      if [ -f ~/.bashrc ]; then

              . ~/.bashrc

      fi

       

      # User specific environment and startup programs

       

      PATH=$PATH:$HOME/bin

       

      export PATH

      ##---------------------------------------------------------------------------------------

       

      Kindly advice how to address this problem ?

       

      Thank you in advance ...

        • 1. Re: java.io.IOException: Cannot run program error=13
          Stephen Coy Master

          Where did you find your jboss-as-domain.sh script and what does it contain?

           

          It looks like the issue is that the jboss user is attempting to access the user's home directory...

          • 2. Re: java.io.IOException: Cannot run program error=13
            Neo Yang Newbie

            hi Stephen,  the jboss-as-domain.sh is modified base on jboss-as-standalone.sh for domain. Below is the cmd in the script.

             

            JBOSS_CONFIG=domain.xml

            JBOSS_SCRIPT=$JBOSS_HOME/bin/domain.sh

            LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT -c $JBOSS_CONFIG 2>&1 > $JBOSS_CONSOLE_LOG &

            • 3. Re: java.io.IOException: Cannot run program error=13
              Stephen Coy Master

              You might try:

               

              {code}sudo -H -u jboss ...{code}

               

              If your sudoers file is set up correctly this will change the HOME environment variable to that of the jboss user.

              • 4. Re: java.io.IOException: Cannot run program error=13
                Ranga Raju Venkata Surya Newbie

                Still getting the same error even with sudo -H -u jboss .

                • 5. Re: java.io.IOException: Cannot run program error=13
                  Wolf-Dieter Fink Master

                  I'm a bit confused about

                  the jboss-as-domain.sh is modified base on jboss-as-standalone.sh for domain. Below is the cmd in the script.

                   

                  In the script there is a handling for JBOSS_USER, what if you set this variable and start the script as root?

                  • 6. Re: java.io.IOException: Cannot run program error=13
                    Ranga Raju Venkata Surya Newbie

                    That setting is already there.

                     

                    The probelm happened because of the below :

                    -------------------------

                    When a user performs a command with sudo, certain information is entered in to the “run as” user’s environment as environment variables. The variables are SUDO_USER, SUDO_UID, SUDO_GID, and SUDO_COMMAND.  This does not happen when you take the extra step of sudo su - <user>, and then issue the same commands from within that shell that would otherwise be run directly through sudo.

                     

                    What it looks like might be happening is that the SUDO_USER environment variable is being referenced to determine who is originating the command, and the java process tries to set its working directory to the originating user’s home directory.  I really don’t see any other way for that information to be getting through to the java process when it is started directly from the user via sudo vs. not when using sudo su – jboss and then launching the command.

                    -------------------------

                    So to address the above issue, what I had to do was, I created a wrapper shell script that would be invoked as follows:

                                   sudo –u jboss /app_mgmt/redhat/buildScripts/scripts/recycle-jboss-as-7-domain.ksh stop

                                   sudo –u jboss /app_mgmt/redhat/buildScripts/scripts/recycle-jboss-as-7-domain.ksh start

                     

                    Inside the script I am performing the two steps:

                     

                                   cd /opt/jboss/jboss-as-7.1.1.Final/bin/init.d

                                   ./jboss-as-domain.sh ${ARG_PASSED}

                     

                    Now the user is able to start and stop the jboss process without having full sudo to jboss userid but with access to the above commands as himself.

                     

                    Thank you all for your help. the issue is now resolved.