Determine Which Application Server our application is deployed to?

空扰寡人 提交于 2019-12-01 18:31:33
skaffman

Simplest thing I can think of is to look through the system properties at runtime, since both servers are almost certainly going to define their own. For example, JBoss 4 defines the jboss.server.dir system property. Check to see if that property exists, and if it does, then you can assume you're running under that server. OC4J will have something similar.

Alternatively, try reflectively loading a class that is part of the server's infrastructure (e.g. org.jboss.Version in JBoss 4). If it exists, you know what server you're on.

You can find this out by ServletContext#getServerInfo().

Most likely JMX is what you are going to need to use. Both containers likely expose details about themselves as MBeans. Here is some Oracle documentation on JMX and JBoss documentation.

Marc Dzaebel

Change to System.getProperty("jboss.home.dir")

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!