Thursday, April 1, 2010

Stop and uninstall an application using wsadmin

Before the application can be unsinstalled it must be stopped.
Steps:

1. Open wsadmin (with jython)
1.1 Go to "WebSphere_Profile_Root"/bin
1.2 Execute
wsadmin.sh(.bat) -lang jython
1.3 Enter UserID/Password (if promted)

2. Define needed cell and node variables
2. Execute
cell=AdminConfig.list('Cell')
cellname=AdminConfig.showAttribute(cell,'name')
nodes=AdminConfig.list('Node',cell)
nodename=AdminConfig.showAttribute(nodes,'name')
-----------------------------------
(Alternative:
e.g.: nodename=NAME_OF_NODE)

3. Define application manager variable
3.1 Execut
appManager=AdminControl.queryNames
('type=ApplicationManager,cell='+cellname+',
node='+nodename+',process=<APP_SERVER_NAME>,*')
3.2 To print out variable execute
print appManager
4. Assign application to variable
4.1 Execute
app=AdminControl.queryNames
('type=Application,cell='+cellname+',node='+nodename+',
process=<APP_SERVER_NAME>,J2EEName=<NAME_OF_APPLICATION>,*')
4.2 To print out variable execute
print app
5. Define application name to variable
5.1 Execute
appName=AdminControl.getAttributes(app,'name')
5.2 To print out variable execute
print appName
6. Stop application
6.1 Execute
AdminControl.invoke(appManager,'stopApplication', appName)
7. Uninstall application
7.1 Execute
AdminApp.uninstall(appName)
8. Save changes
8.1 Execute
AdminConfig.save()


Hint:
It is easier to use administrative console :-)
<APP_SERVER_NAME> = Name of server (JVM) where the application is deployed
<NAME_OF_APPLICATION> = Name of the application (not the ear-files name)

Install and start an application using wsadmin

opy the application ear-file to <WAS_PROFILE_ROOT>/installableApps

1. Open wsadmin (with jython)
1.1 Go to "WebSphere_Profile_Root"/bin
1.2 Execute
wsadmin.sh(.bat) -lang jython
1.3 Enter UserID/Password (if promted)

2. Define needed cell and node variables
2. Execute
cell=AdminConfig.list('Cell')
cellname=AdminConfig.showAttribute(cell,'name')
nodes=AdminConfig.list('Node',cell)
nodename=AdminConfig.showAttribute(nodes,'name')
-----------------------------------
(Alternative:
e.g.: nodename=NAME_OF_NODE)


3. Install application
3.1 Execute
AdminApp.install('../installableApps/<NAME_OF_EAR_FILE>',['-appname <NAME_OF_APPLICATION>'])

4. Save changes
4.1 Execute
AdminConfig.save()

5. Define application manager variable
5.1 Execute
appManager=AdminControl.queryNames
('type=ApplicationManager,cell='+cellname+',
node='+nodename+',process=,*')
5.2 To print out variable execute
print appManager
6. Assign application to variable
6.1 Execute
app=AdminControl.queryNames
('type=Application,cell='+cellname+',node='+nodename+',
process=,J2EEName=,*')
6.2 To print out variable execute
print app
7. Define application name to variable
7.1 Execute
appName=AdminControl.getAttributes(app,'name')
7.2 To print out variable execute
print appName
8. Start application
8.1 Execute
AdminControl.invoke(appManager, 'startApplication',appName)


Hint:
It is easier to use administrative console :-)
<APP_SERVER_NAME>= Name of server (JVM) where the application is deployed
<NAME_OF_APPLICATION> = Name of the application (not the ear-files name)

Export / Import LTPA-Keys for Single Sign On (SSO)

Sometimes its necessary to implement an SSO-Enviroment over different WebSphere-Cells (e.g. Production-Cell and Acceptance-Cell). To do this both cells need the same LTPA-Keys.
The synchronization of LTPA-Keys can be done over Admin-Console.

1. To Export LTPA-Keys from a Cell navigate to
Security > Secure administration, applications, and infrastructure > Authentication mechanisms and expiration.

2. Fill out the import/export-Form at the bottom of the page

and click "Export keys". The LTPA-Keys will be exported to the specified directory. (The Keys will be password protected.)

3. Copy the exported ltpa.jceks-File to other the Cell (do not override ltpa.jceks of this cell).

4. Take a look at ltpa.jceks-File of this cell and note the file-size.
File is located in /"websphere"/"dmgr"/config/cells/"cellname"/ltpa.jceks

5. To import the LTPA-Keys to other Cell navigate to
Security > Secure administration, applications, and infrastructure > Authentication mechanisms and expiration.

6. Fill out "Cross-cell Single sign on"-From and click "Import keys"

7. File size of ltpa.jceks-File of this Cell should now be increased.
Sometimes nothing happens to file size of ltpa.jceks-File and Cross-cell SSO will not work (WAS-Bug).
In this case just repeat the import.

8. Restart servers/node