tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amit Pande <>
Subject Re: Using JMX to get ONLY running applications
Date Wed, 13 Jul 2016 10:14:38 GMT
Can someone help here ?

It seems the stateName attribute of MANAGER or WEBMODULE Mbean is NOT
getting set correctly if there are any servlet errors.

In particular, when Spring dispatcher servlet is failed to load then the
applications state should be STOPPED. However, that does not seem to be
the case.

I even checked the SERVLET Mbean as well did not see the expected state.

Is there anything wrong that I am doing ? Is this a BUG ? Using Tomcat


On 13/07/16 1:05 pm, "Amit Pande" <> wrote:

>I managed to use jCOnsole and find Mbean names and attributes to get the
>stateName (STARTED/STOPPED) to see if a web app is available or NOT
>However, I see the stateName of a web module as STARTED even if there are
>errors in start-up.
> SEVERE [localhost-startStop-3]
>org.apache.catalina.core.StandardContext.loadOnStartup Servlet
>[dispatcher] in web application [/testApp] threw load() exception
>I still see state for testApp as "STARTED".
>How can I accurately know if the application is started without any
>errors ?
>Appreciate your help.
>From: Amit Pande <<>>
>Date: Tuesday, 12 July 2016 9:56 pm
>To: "<>"
>Subject: Using JMX to get ONLY running applications
>Hello all,
>I see there are JMX APIs to get the web applications currently deployed
>in Tomcat.
>However, I see that even if the applications are failed to deploy, they
>still get listed. Is there any way to get ONLY deployed and RUNNING
>applications ?
>Below is sample snippet which gives all the currently deployed apps
>..even if there are some apps which had errors and thus failed to deploy:
>public List<String> collectAllDeployedApps() throws
>MalformedObjectNameException, AttributeNotFoundException,
>InstanceNotFoundException, MBeanException, ReflectionException {
>List<String> webappNames = new ArrayList<>();
>List<MBeanServer> servers =  MBeanServerFactory.findMBeanServer(null);
>for (MBeanServer server : servers ) {
>Set<ObjectName> names = server.queryNames(new
>ObjectName("Catalina:type=Host,*"), null);
>Set<String> hostNames = new HashSet<String>();
>for (ObjectName on : names) {
>for (String str : hostNames) {
>ObjectName[] webapps = (ObjectName[]) server
>.getAttribute(new ObjectName("Catalina:type=Host,host=" + str),
>for (ObjectName ob : webapps) {
>String[] appSpl = ob.getKeyProperty("name").split("//localhost");
>return webappNames;

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message