Ken
$WAS_INSTALL_ROOT/bin/wsadmin.sh -user -password -c '$AdminApp list'
Hope this helps
Bob
I'm also interested in getting the application name: Shelley, did you find how to sort this out? FYI, my target is to check, from my application itself, if WebSphere configuration is okay (in my very particular case, if session management setup has been rightly configured and otherwise, to raise a warning during application startup).
I think this could be feasible, thanks to the com.ibm.websphere.management.configservice.ConfigService, but I need to know the deployed application name before calling ConfigService.resolve() method.
To work around this, I have been inspecting the path returned by a known resource's URL. Something similar to the following:
{code}
final URL url = getClass().getResource(getClass().getSimpleName() + ".class");
{code}
Assuming this class is being loaded from the application or module class loader (as opposed to the extensions class loader, for instance) [1], and that WebSphere's ClassLoader implementations consistently load resources from the application installation directory [2], you can generally determine the name of the application.
It's not ideal and makes some assumptions about WAS's internal ClassLoader implementations (ie: how getResource() is implemented), but +so far+ seems to do the trick. I've started discussing this a bit with IBM, and hope that they might introduce such a feature since this request doesn't seem that uncommon (nor, I would think, difficult to implement).
[1] http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/topic/com.ibm.websphere.nd.doc/info/ae/ae/crun_classload.html
[2] http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/urun_rapp_installoptions.html
You can use the debugger to get a list of valid attributes. But one more time, it makes an assumption on internal WebSphere mechanism.
For example:
IBM WebSphere Developer Technical Journal: System Administration for WebSphere Application Server V5
Part 2 -- Writing Your Own Administration Programs
http://www.ibm.com/developerworks/websphere/techjournal/0302_cundiff/cundiff.html
The code below lists all applications deployed on the WAS
//obtain config service
ConfigService configService = ...
ObjectName objName = ConfigServiceHelper.createObjectName(null, "Deployment",null);
ObjectName[] objNames = configService.queryConfigObjects(session,null,objName ,null);
for (int i=0; iobjNames.length;i++){
String appName = objNames.getKeyProperty(SystemAttributes._WEBSPHERE_CONFIG_DATA_DISPLAY_NAME);
System.out.println("Application: "+appName);
}
Could you write one auto-start servlet that doesn't have any doXXX()
methods, just an init() that grabs something from the context and shoves
it into the System properties?
If not, where will your code be executing?
Ken