Siddharth Shankar
Siddharth Shankar

Reputation: 539

Is there any way we could figure out in code the environment where EAR is deployed?

I am facing an issue in my restlet project where I have to code some operations only if the EAR is deployed in Websphere in a restlet server project. Is there any way we can get information through code to find out where is EAR/WAR deployed? (Is the EAR is deployed in Websphere or Tomcat or other servers).

Upvotes: 0

Views: 57

Answers (2)

Gas
Gas

Reputation: 18050

If you only need to check that for example in Servlet/Filter class you can look for servlet context attributes related to WebSphere, for example com.ibm.websphere.servlet.application.name = Default Web Application. You can find some attributes looi=king at the /snoop servlet if you have that installed.

Or, as Bruce suggested try to load some WebSphere class and be prepared for errors when they are not there.

Upvotes: 0

Bruce T.
Bruce T.

Reputation: 1002

Try to instantiate some WebSphere API class. If you get a NoClassDefFound, it's probably not running on WebSphere. You might have to do class.forName(Websphere class), so your code will compile outside websphere.

Upvotes: 1

Related Questions