Showing posts with label WLST. Show all posts
Showing posts with label WLST. Show all posts

06 May 2011

Calling a WLST script from Ant







Code

build.xml
<?xml version="1.0" encoding="windows-1252" ?>
<project name="Run WLST project" default="run-wlst-script">
  <property file="wlst.properties"/>
  
  <taskdef name="wlst" classname="weblogic.ant.taskdefs.management.WLSTTask">
    <classpath>
      <pathelement location="${weblogic.lib.dir}/weblogic.jar"/>
    </classpath>
  </taskdef>
  
  <target name="run-wlst-script">
    <wlst debug="true" failonerror="true" filename="wlst.script.source">
      <classpath>
        <pathelement location="${weblogic.lib.dir}/weblogic.jar"/>
      </classpath>
    </wlst>
  </target>
  
</project>

And the property file

weblogic.home.dir=C:/Oracle/Middleware/wlserver_10.3
weblogic.lib.dir=${weblogic.home.dir}/server/lib
wlst.script.source=C:/JDeveloper/mywork/tmp/Set_Complete_Message_Timeout_script.py


Thanx again Serafim's for another good post!

Record in a WLST script the actions performed in Weblogic console


First set some configuration before start recording
Click Preferences,
Select WLST Script Recording,
Select General,
Here you can set
  • the location that the script will be saved (Base Script Directory)
  • the filename (Script File Name)
  • if in each recording will overwrite the previous one or will be appended to the end of file (Append To File)
  • if you must first "Lock & Edit" before start recording (Require Lock)



To start recording 
Click "Lock & Edit"

Select Control

Select Start Recoriding



Alternative you can click Record on top of the page to start recording.

When you finish you click "Stop Recording" to stop the recording.

After the recording is completed, you can find the recording or in the "Recorded commands"
 or in the script saved in the server at the location we defined above.

TROUBLESHOOTING: Exception while trying to execute a recorded session
Error
     [wlst]   File "C:\JDeveloper\mywork\tmp\Set_Complete_Message_Timeout_script.py", line 7, in ?
     [wlst] AttributeError: setFrontendHTTPSPort
     [wlst]
     [wlst] Exception in thread "main" java.lang.IllegalStateException: Traceback (innermost last):
     [wlst]   File "C:\JDeveloper\mywork\tmp\Set_Complete_Message_Timeout_script.py", line 7, in ?
     [wlst] AttributeError: setFrontendHTTPSPort
     [wlst]
     [wlst]     at weblogic.management.scripting.WLSTInterpreterInvoker.printError(WLSTInterpreterInvoker.java:110)
     [wlst]     at weblogic.management.scripting.WLSTInterpreterInvoker.executePyScript(WLSTInterpreterInvoker.java:103)
     [wlst]     at weblogic.management.scripting.WLSTInterpreterInvoker.main(WLSTInterpreterInvoker.java:27)

Reason
Sometimes the recording tool does not record the Node in the Domain Structure were you clicked in order to make your changes. For example if you change the Server "Duration" setting (HTTP Keep Alive) and record you might get something like
eg
startEdit()
cd('/Servers/DefaultServer/WebServer/DefaultServer')
cmo.setKeepAliveSecs(33)
activate()
Beware because sometimes the " cd('/Servers/DefaultServer/WebServer/DefaultServer')" might be missing and only the following might be recorded 
startEdit()
cmo.setKeepAliveSecs(33)
activate()

This will give the Exception mentioned above.

Preparing a recorded script before running
Before  running the recorded script make sure to have the proper cd() commands as mentioned in the TROUBLESHOOTING section.

Finally, in order t connect/disconnent/prepare add the following:


connect('weblogic','weblogic1','t3://localhost:7101')
edit()
startEdit()
cd('/Servers/DefaultServer/WebServer/DefaultServer')
cmo.setKeepAliveSecs(33)
save()
activate()
disconnect()
exit()



Thanx to Serafim for his excellent post (in Greek).


Dig more:

You might also like:

Related Posts Plugin for WordPress, Blogger...