tputkonen
tputkonen

Reputation: 5729

How to determine type of Application Server an application is running on?

Our EJB3 application can run on top of Oracle AS or JBoss AS. Is there a way to find out type of AS during runtime?

Upvotes: 4

Views: 3995

Answers (2)

paulsm4
paulsm4

Reputation: 121599

Another way is to check for an app-server specific value in System properties.

// EXAMPLE:
if (System.getProperty("catalina.base") != null) {
  // Using Tomcat
  ...
else if (System.getProperty("jboss.server.name") != null) {
  // Using JBoss
  ...
else if (System.getProperty("was.install.root") != null) {
  // Using WebSphere
  ...

Upvotes: 2

ewernli
ewernli

Reputation: 38605

You can check the concrete type of object at runtime using reflection, e.g. the EJBContext that is injected by the app. server.

Upvotes: 1

Related Questions