Using the script library to automate the application serving environment using wsadmin scripting
The script library provides Jython script procedures to assist in automating your environment. Use the sample scripts to manage applications, resources, servers, nodes, and clusters. You can also use the script procedures as examples to learn the Jython syntax.
About this task
The Jython script library provides a set of procedures to automate the most common application server administration functions. For example, you can use the script library to easily configure servers, applications, mail settings, resources, nodes, business-level applications, clusters, authorization groups, and more. You can run each script procedure individually, or combine several procedures to quickly develop new scripts.
- Run scripts from the Jython script library in interactive mode
with the wsadmin tool. You can launch the wsadmin tool, and run individual
scripts that are included in the script library using the following
syntax:
wsadmin>AdminServerManagement.createApplicationServer("myNode", "myServer", "default")
- Use a text editor to combine several scripts from the Jython script library, as the following
sample
displays:
Save the custom script and run it from the command line, as the following syntax demonstrates:# # My Custom Jython Script - file.py # AdminServerManagement.createApplicationServer("myNode", "Server1", "default") AdminServerManagement.createApplicationServer("myNode", "Server2", "default") # Use one of them as the first member of a cluster AdminClusterManagement.createClusterWithFirstMember("myCluster", "APPLICATION_SERVER", "myNode", "Server1") # Add a second member to the cluster AdminClusterManagement.createClusterMember("myCluster", "myNode", "Server3") # Install an application AdminApplication.installAppWithClusterOption("DefaultApplication", "..\installableApps\DefaultApplication.ear", "myCluster") # Start all servers and applications on the node AdminServerManagement.startAllServers("myNode")
bin>wsadmin -language jython -f path/to/your/jython/file.py
- Use the Jython scripting library code as sample syntax to write custom scripts. Each script example in the script library demonstrates best practices for writing wsadmin scripts. The script library code is located in the app_server_root/scriptLibraries directory. Within this directory, the scripts are organized into subdirectories according to functionality. For example, the app_server_root/scriptLibraries/application/V70 subdirectory contains procedures that perform application management tasks that are applicable to Version 7.0 and later of the product. The subdirectory V70 in the script library paths does not mean the scripts in that subdirectory are Version 7.0 scripts.
bin>wsadmin -lang jython -javaoption "-Dwsadmin.script.libraries=c:/myJythonScripts"
bin>wsadmin -lang jython -javaoption "-Dwsadmin.script.libraries=c:/myJythonScripts;c:/AdminScripts;c:/configScripts"
The script library provides automation scripts for the following application server administration functions:
Procedure
- Manage application servers.
You can use the AdminServerManagement scripts to configure classloaders, Java™ virtual machine (JVM) settings, Enterprise JavaBeans (EJB) containers, performance monitoring, dynamic cache, and so on.
- Manage server and system architecture.
You can use the AdminServerManagement script library to manage server settings.
- Manage applications.
You can use the AdminApplication scripts to install, uninstall, and update your applications with various options.
- Manage data access
resources. You can use the AdminJDBC and AdminJ2C script libraries to manage data sources and Java Database Connectivity (JDBC) providers, and to create and configure Java 2 Connector (J2C) resource adapters.
- Manage messaging resources.
You can use the AdminJMS script library to configure and manage your Java Messaging Service (JMS) configurations.
- Manage mail resources.
You can use the AdminResources scripts in the script library to configure mail, URL, and resource settings.
- Managing authorization
groups. You can use the AdminAuthorizations scripts to configure authorization groups.
- Monitor performance and troubleshoot configurations.
You can use the AdminUtilities scripts to configure trace, debugging, logs, and performance monitoring. See the Utility scripts topic.
- Get script library help
using wsadmin You can use the AdminLibHelp script library to list each available script library, display information for specific script libraries, and to display information for specific script procedures.
What to do next
Determine which scripts to use to automate your environment, or create custom scripts using assembly tools.