Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting instance name of a WebSphere app Server

Tags:

java

websphere

My Web service will run on a Jboss App Server or a Websphere app Server. For both of them I need to know the instance name, for Jboss I can use System.getProperty("jboss.server.name"), but what can I use for WebSphere? I can't use WebSphere-specific methods, I need to call System.properties

Thanks

like image 361
Michele Bortolato Avatar asked May 16 '12 12:05

Michele Bortolato


People also ask

What is WebSphere instance?

WebSphere® Application Server is a comprehensive, sophisticated, Java™ 2 Enterprise Edition (J2EE) and Web services technology-based application system.

How can I change WebSphere Application Server name?

For the application server, select Servers > Server Types > WebSphere application servers > application_server > Ports. Select a port whose host name needs changing. Change the host name in the Host field; Click OK.


1 Answers

An alternative, at least for WebSphere, is to look it up in the JNDI tree. This is what I use:

InitialContext ic = new javax.naming.InitialContext();
String serverName = ic.lookup("servername").toString();

This way I don't have to configure anything as WebSphere binds that information for me.

Cell and node name can also be retrieved using "thisNode/cell/cellname" and "thisNode/nodename". Something useful in clusters.

like image 129
IsidroGH Avatar answered Sep 21 '22 15:09

IsidroGH