tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amit Pande <Amit.Pa...@veritas.com>
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
8.0.30.

Thanks,
Amit



On 13/07/16 1:05 pm, "Amit Pande" <Amit.Pande@veritas.com> 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
>(j2eeType=WebModule).
>
>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.
>
>Thanks,
>Amit
>
>From: Amit Pande <Amit.Pande@Veritas.com<mailto:Amit.Pande@Veritas.com>>
>Date: Tuesday, 12 July 2016 9:56 pm
>To: "users@tomcat.apache.org<mailto:users@tomcat.apache.org>"
><users@tomcat.apache.org<mailto:users@tomcat.apache.org>>,
>"users-help@tomcat.apache.org<mailto:users-help@tomcat.apache.org>"
><users-help@tomcat.apache.org<mailto:users-help@tomcat.apache.org>>
>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) {
>hostNames.add(on.getKeyProperty("host"));
>}
>for (String str : hostNames) {
>ObjectName[] webapps = (ObjectName[]) server
>.getAttribute(new ObjectName("Catalina:type=Host,host=" + str),
>"children");
>for (ObjectName ob : webapps) {
>String[] appSpl = ob.getKeyProperty("name").split("//localhost");
>System.out.println(ob.getKeyPropertyList());
>webappNames.add(appSpl[1]);
>}
>}
>}
>return webappNames;
>}
>}
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message