两种不同的运行wlst脚本的方式

第一种方法:
    <java classname="weblogic.WLST" fork="false" failOnError="true">
        <classpath refid="wls.classpath" />
        <arg line="wlst/createCluster.py mydomain" />
    </java>
成功执行

第二种方法
    <taskdef name="wlst"
             classname="weblogic.ant.taskdefs.management.WLSTTask"
             classpathref="wls.classpath" />

    <wlst fileName="wlst/createCluster.py"
          arguments="mydomain"
          debug="true"
          failOnError="true">
    </wlst>
运行上面脚本后,ant输出如下内容,抛出了异常,但是执行的结果的是正确的,也就是说创建的域是正确的,但是在脚本的最后执行exit()方法时,抛出了异常,我想这里的问题应该是fork的问题,在第一个方法中可以自行控制启动的是否是一个独立的进程,而第二种方法不能控制,只能是一个进程,所以在执行exit()方法时,不但退出了wlst脚本的执行,也退出了ant进程。

wlst.creatCluster:
     [wlst] <WLSTTask> Adding test1 to sys.argv
     [wlst] <WLSTTask> sys.argv is ['wlst/createCluster.py', 'test1']
     [wlst] <WLSTTask> The script that will be executed
     [wlst] Exiting WebLogic Scripting Tool.

BUILD FAILED
F:/work_topfounder/workspace/callcenter/build-wls.xml:185: Traceback (innermost last):
  File "wlst/createCluster.py", line 127, in ?
  File "<iostream>", line 46, in exit
org.eclipse.ant.internal.ui.antsupport.AntSecurityException
 at org.eclipse.ant.internal.ui.antsupport.AntSecurityManager.checkExit(AntSecurityManager.java:54)
 at java.lang.Runtime.exit(Runtime.java:88)
 at java.lang.System.exit(System.java:868)
 at weblogic.management.scripting.WLScriptContext.exit(WLScriptContext.java:579)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:160)
 at org.python.core.PyMethod.__call__(PyMethod.java:96)
 at org.python.core.PyObject.__call__(PyObject.java:283)
 at org.python.core.PyObject.invoke(PyObject.java:2055)
 at org.python.pycode._pyx6.exit$3(<iostream>:46)
 at org.python.pycode._pyx6.call_function(<iostream>)
 at org.python.core.PyTableCode.call(PyTableCode.java:208)
 at org.python.core.PyTableCode.call(PyTableCode.java:404)
 at org.python.core.PyTableCode.call(PyTableCode.java:253)
 at org.python.core.PyFunction.__call__(PyFunction.java:169)
 at org.python.pycode._pyx16.f$0(wlst/createCluster.py:127)
 at org.python.pycode._pyx16.call_function(wlst/createCluster.py)
 at org.python.core.PyTableCode.call(PyTableCode.java:208)
 at org.python.core.PyCode.call(PyCode.java:14)
 at org.python.core.Py.runCode(Py.java:1135)
 at org.python.core.__builtin__.execfile_flags(__builtin__.java:308)
 at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:158)
 at weblogic.management.scripting.utils.WLSTInterpreter.execfile(WLSTInterpreter.java:305)
 at weblogic.ant.taskdefs.management.WLSTTask.execute(WLSTTask.java:108)
 at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
 at org.apache.tools.ant.Task.perform(Task.java:364)
 at org.apache.tools.ant.Target.execute(Target.java:341)
 at org.apache.tools.ant.Target.performTasks(Target.java:369)
 at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
 at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
 at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
 at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
 at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
 at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
 at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)

org.eclipse.ant.internal.ui.antsupport.AntSecurityException: org.eclipse.ant.internal.ui.antsupport.AntSecurityException 

你可能感兴趣的:(function,weblogic,ant,脚本,iostream,scripting)