5 Replies Latest reply on Oct 23, 2009 2:30 PM by Vinnie Lima

    RedHatRepositoryManager.nsh -  Unable to access jarfile

    Vinnie Lima

      Attempting to setup an NSH Script Job so that the Red Hat Repository is Yummified automatically on a weekly basis.

       

      I added the script RedHatRepositoryManager.nsh into Depot, then proceeded in creating the job.

       

      When I run the job (with the right parameters), the job is getting these errors:

       

      Info    Oct 22, 2009 3:42:53 PM    Checking default java version.... 1.5.0_20
      Info    Oct 22, 2009 3:42:54 PM    Exit Code 1
      Error    Oct 22, 2009 3:42:54 PM    Unable to access jarfile libs/RedHatRepositoryManager.jar

       

      Seems again that the nexec to the target machine fails to incorporate the environment.  What parameter should I be passing to either the Job or NSH script to overcome this error?

       

      Below are the permissions of the jar file.  The command on the target machine (same as app server) is running as root.

       

      emda-nbp-uea21% ls -al
      total 4649
      drwxr-xr-x   2 bladmin  bladmin      4096 Sep 11 17:11 .
      drwxr-xr-x   3 bladmin  bladmin      4096 Oct 22 15:03 ..
      -rwxr-xr-x   1 bladmin  bladmin       393 Sep 11 17:11 RHRM_credentials.stg
      -rwxr-xr-x   1 bladmin  bladmin       751 Apr 21  2009 RedHatRepositoryManager.gm
      -rwxrwxrwx   1 bladmin  bladmin    210518 Jun 24 19:12 RedHatRepositoryManager.jar
      -rwxr-xr-x   1 bladmin  bladmin     36174 May 19  2008 commons-cli-1.1.jar
      -rwxr-xr-x   1 bladmin  bladmin     46725 May 05  2008 commons-codec-1.3.jar
      -rwxr-xr-x   1 bladmin  bladmin    305001 May 05  2008 commons-httpclient-3.1.jar
      -rwxr-xr-x   1 bladmin  bladmin     52915 May 05  2008 commons-logging-1.1.jar
      -rwxr-xr-x   1 bladmin  bladmin     21713 Feb 20  2008 createrepo-0.4.6-1.el4.rf.noarch.rpm
      -rwxr-xr-x   1 bladmin  bladmin    483640 Apr 17  2008 http.jar
      -rwxr-xr-x   1 bladmin  bladmin    367444 May 05  2008 log4j-1.2.14.jar
      -rwxr-xr-x   1 bladmin  bladmin     10259 Jul 25  2008 make-hdrcache.pl
      -rwxr-xr-x   1 bladmin  bladmin     94292 Feb 20  2008 python-urlgrabber-2.9.6-1.2.el4.rf.no
      arch.rpm
      -rwxr-xr-x   1 bladmin  bladmin     34840 May 05  2008 ws-commons-util-1.0.1.jar
      -rwxr-xr-x   1 bladmin  bladmin       596 Jun 24  2008 xmllog4jconfig.xml
      -rwxr-xr-x   1 bladmin  bladmin     43312 May 05  2008 xmlrpc-client-3.0.jar
      -rwxr-xr-x   1 bladmin  bladmin     98051 May 05  2008 xmlrpc-common-3.0.jar
      -rwxr-xr-x   1 bladmin  bladmin    133342 Dec 14  2007 yum-2.0.8-1.noarch.rpm
      -rwxr-xr-x   1 bladmin  bladmin    426839 Jun 19  2008 yum-arch-2.2.2-2.el5.noarch.rpm

        • 1. Re: RedHatRepositoryManager.nsh -  Unable to access jarfile
          Bill Robinson

          I don't think it's permissions, I think it might be a path issue.  Can you post the script that's calling this?

          • 2. Re: RedHatRepositoryManager.nsh -  Unable to access jarfile
            Vinnie Lima

            I think the problem is that the nsh script is being run on the remote system and uses relative pathing. The script assumes that its placed under a certain directory. I don't know how, through the job, to define how to extend a full environment to the script or force the script to run in a certain location on the remote system.

             

            Thanks.

             

             

             

            #!nsh

             

            # main function
            # -------------

             

            JAVA="java"

             

            check_java_version()
            {
                ver=`$JAVA -version 2>&1 | grep "java version" | tr -d '\n' | tr -d '\r'`
                ver=`echo "$ver" | sed -e 's/^[a-zA-Z0-9\ ]*"//' | sed -e 's/"//'`
                echo " $ver"
                mf=`echo "$ver" | cut -d '.' -f 1 | sed -e 's/^[0]*//g'`
                ms=`echo "$ver" | cut -d '.' -f 2 | sed -e 's/^[0]*//g'`

             

                test -n "$ms"
                if [ "$?" -ne "0" ]; then
                    ms="0"
                fi

             

                test -n "$mf"
                if [ "$?" -ne "0" ]; then
                    mf="0"
                fi

             

                if [ "$mf" -lt "1" ]; then
                    echo "Java version 1.5.0 or above required\n"
                    return 0
                fi

             

                if [ "$mf" -eq "1" -a "$ms" -lt "5" ]; then
                    echo "Java version 1.5.0 or above required\n"
                    return 0
                fi
                return 1
            }

             

            use_appserver_java_path()
            {
                OS=`uname -s`
                if [ "$OS" != "WindowsNT" ]; then
                    if [ ! -f /usr/lib/rsc/HOME ];then
                        echo "Cannot get AppServer installed location"
                        return 0
                    fi
                    JAVA=`cat "/usr/lib/rsc/HOME" | sed -e 's/[ \t]+$//g'`/br/java/bin/java
                else
                    home_file=`echo -n "/$SYSTEMROOT" | sed -e 's/:\\\\/\//g' | sed -e 's/\\\\/\//g'`
                    if [ ! -f $home_file/rsc/HOME ];then
                        echo "Cannot get AppServer installed location"
                        return 0
                    fi
                    JAVA=`cat "$home_file/rsc/HOME" | sed -e 's/[ \t]+$//g' | tr -d "\015"`
                    JAVA="$JAVA/jre/bin/java"
                fi
                if check_java_version; then
                    return 0
                fi
                return 1
            }

             


            IFS=''
            echo -n "Checking default java version...."
            if check_java_version; then
                echo -n "Checking AppServer java version...."
                if use_appserver_java_path;then
                    exit 1
                fi
            fi
            $JAVA -Xms32m -Xmx128m -jar libs/RedHatRepositoryManager.jar "$@"
            exit $?

            • 3. Re: RedHatRepositoryManager.nsh -  Unable to access jarfile
              Bill Robinson

              I usually call this w/ a wrapper script instead of loading it directly into the cm.

              • 4. Re: RedHatRepositoryManager.nsh -  Unable to access jarfile
                Vinnie Lima

                Do you have an example wrapper script that I can leverage?

                • 5. Re: RedHatRepositoryManager.nsh -  Unable to access jarfile
                  Vinnie Lima

                  Nevermind - got it.

                   

                  Wrapper shell script works, just make sure to use the PERL option for the script.