Example: Configuring a shared library using wsadmin
The following example configures an appserver to use a shared library.
- Identify the server and assign it to the server variable:
Using Jacl:
set server [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]
Using Jython:
server = AdminConfig.getid('/Cell:mycell/Node:mynode/Server:server1/') print server
Example output:
server1(cells/mycell/nodes/mynode/servers/server1:server.xml#Server_1)
- Create the shared library in the server:
Using Jacl:
$AdminConfig create Library $server {{name mySharedLibrary} {classPath c:/mySharedLibraryClasspath}}
Using Jython:
print AdminConfig.create('Library', server, [['name', 'mySharedLibrary'], ['classPath', 'c:/mySharedLibraryClasspath']])
Example output:
MysharedLibrary(cells/mycell/nodes/mynode/servers/server1:libraries.xml#Library_1)
- Identify the appserver from the server and assign it to the appServer variable:
Using Jacl:
set appServer [$AdminConfig list ApplicationServer $server]
Using Jython:
appServer = AdminConfig.list('ApplicationServer', server) print appServer
Example output:
server1(cells/mycell/nodes/mynode/servers/server1:server.xml#ApplicationServer_1
- Identify the class loader in the appserver and assign it to the classLoader variable.
To use the existing class loader associated with the server, the following commands use the first class loader:
Using Jacl:
set classLoaders [$AdminConfig showAttribute $appServer classloaders] set classLoader [lindex $classLoaders 0]Using Jython:
classLoaders = AdminConfig.showAttribute(appServer, 'classloaders') cleanClassLoaders = classLoaders[1:len(classLoaders)-1] classLoader = cleanClassLoaders.split(' ')[0]Create a new class loader, by doing the following:
Using Jacl:
set classLoader [$AdminConfig create Classloader $appServer {{mode PARENT_FIRST}}]
Using Jython:
classLoader = AdminConfig.create('Classloader', appServer, [['mode', 'PARENT_FIRST']])
Example
output:
(cells/mycell/nodes/mynode/servers/server1:server.xml#Classloader_1)
- Associate the created shared library with the appserver through the class loader.
Using Jacl:
$AdminConfig create LibraryRef $classLoader {{libraryName MyshareLibrary} {sharedClassloader true}}
Using Jython:
print AdminConfig.create('LibraryRef', classLoader, [['libraryName', 'MyshareLibrary'], ['sharedClassloader', 'true']])
Example output:
(cells/mycell/nodes/mynode/servers/server1:server.xml#LibraryRef_1)
- Save the changes with the following command:
Using Jacl:
$AdminConfig save
Using Jython:
AdminConfig.save()