After Exception While Running WLST in Embedded Mode, Terminal Doesn't Return (Doc ID 1279154.1)

Last updated on NOVEMBER 05, 2016

Applies to:

Oracle Weblogic Server - Version: 10.3 and later   [Release: and later ]
Oracle Solaris on SPARC (32-bit)
Oracle Solaris on SPARC (64-bit)
Oracle Solaris on x86 (32-bit)
Oracle Solaris on x86-64 (64-bit)

Symptoms

When running a WLST Script in embedded mode, on Solaris 10, after a particular exception from a malformed deployment descriptor, WLST hangs, showing no exception and not returning to the terminal.

The issue can be reproduced at will by the following steps:

  1. Create a java class with the following code:
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.InputStreamReader;

    import weblogic.management.scripting.utils.WLSTInterpreter;
    import org.python.util.InteractiveInterpreter;

    public class WLSTTester {

      public void testScript(String wlstScript, String domainHome){
        Runtime runtime = Runtime.getRuntime();
        this.runScript(runtime, domainHome+"/deployment_scripts", "/home/dralquinta/WLS/10.3.0/jrockit_160_05/bin/java weblogic.WLST "+wlstScript+"; echo ''");
      }

      public void testEmbededWLST(String wlstScript, String domainHome){
        System.out.println("About to execute "+wlstScript);
        InteractiveInterpreter interpreter = new WLSTInterpreter();


        try {

          interpreter.execfile(domainHome+"/deployment_scripts/"+wlstScript);
        } catch (Exception e){
          System.out.println("FAILED!");
        }
        System.out.println("BAHHHH");
      }

      private void runScript(Runtime runtime, String directory, String script) {
        try {
          System.out.println("about to run script " + script);

          String[] scriptArray = new String[]{"sh", "-c", script};
          Process process = runtime.exec(scriptArray, null, new File(directory));

          BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
          BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream()));

          // read the output from the command
          String s = null;
          System.out.println("Standard output of the command:");
          while ((s = stdInput.readLine()) != null)
          {
            System.out.println(s);
          }

          String errStr = "";

          // read any errors from the attempted command
          System.out.println("Standard error of the command:");
          while ((s = stdError.readLine()) != null)
          {
            System.out.println(s);
            if (errStr.equals("")){
              errStr = s;
            }else{
              errStr += "\n"+s;
            }
          }

          int exitValue = process.waitFor();
          // check for proper exit value
          if (exitValue != 0)
          {
            System.out.println(errStr);
          }
        } catch (Exception e){
          e.printStackTrace();
        }
      }

      /**
      * @param args
      */
      public static void main(String[] args) {
        WLSTTester tester = new WLSTTester();

        String wlstScript = args[0];
        String domainHome = args[1];

        tester.testScript(wlstScript, domainHome);

      }

    }
  2. Set up the environment, by executing: . setDomainEnv.sh.
    NOTE: Note the syntax here: an initial dot followed by a space followed by the invocation of the setDomainEnv script. This initial dot is required to set the environment by some UNIX shells.
  3. Compile with javac and excecute the java class by the following: java WLSTTester test_script.py <WLS_HOME>/user_projects/domains/3-2242181861
  4. The Jython code that has to be created must look like the following:
    import sys
    from java.lang import System

    connect ('weblogic_username','weblogic_password,'t3://IP:PORT')
    print "Deploying Application ivvm - Verse Management System"

    edit()
    startEdit()

    deploy('ivvm.vmsa','<PATH>/ivvm.vmsa.ear', targets='ms1',stageMode='nostage',forceUndeployTimeout=600000,timeout=900000)
    print "Setting Deploy Order for Application ivvm.vmsa to 1000"
    cd('/AppDeployments/ivvm.vmsa')
    cmo.setDeploymentOrder(1000)
    cmo.setNotes('2010/10/26 8:53:6 - Application Deployed via Auto-migration Tool Client')


    try:
    save()
    activate(timeout=900000,block="true")
    print "script returns SUCCESS"
    except Exception,err:
    print err
    print >> sys.stderr,err
    dumpStack()
    exit(exitcode=105)
    try:
    startApplication('ivvm.vmsa',timeout=900000)
    print "Application ivvm.vmsa Deployed Successfully"
    except Exception,err:
    print err
    print >> sys.stderr,err
    print "Start of Component ivvm.vmsa Failed!"
    dumpStack()
    exit(exitcode=108)

Whenever the standard procedure to deploy applications on a WLS Environment becomes unavailable, a good practice is to use WLST to perform deployments. This situation happens when there are over 100 different applications deployed on the application server.


Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms