2 Replies Latest reply on Nov 23, 2010 7:22 PM by Gerald Turner

    Servlet+MBean dependency broken in EAR=SAR+WAR deployment on JBoss 5.1.0

    Gerald Turner Newbie

      I have an EAR with the following structure:

       

        app.ear:
          + META-INF/application.xml
          + META-INF/jboss-app.xml
          + lib/commons-whatever.jar
          + app.sar:
              + META-INF/jboss-service.xml
              + com/wherever/AppService.class
          + app.war:
              + WEB-INF/jboss-web.xml
              + WEB-INF/web.xml
              + WEB-INF/classes/com/wherever/AppServlet.class

       

      The jboss-web.xml in the WAR contians a depends element which matches what is declared in jboss-service.xml in the SAR:

       

        <depends>com.wherever:service=AppService</depends>

       

      The servlet init method invokes a method of the MBean and fails:

       

        javax.management.InstanceNotFoundException: com.wherever:service=AppService is not registered.
          at org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistry.java:526)
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:662)
          at com.wherever.AppServlet.init(AppServlet.java:123)
          at javax.servlet.GenericServlet.init(GenericServlet.java:212)
          at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
          at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:777)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
          at org.jboss.web.tomcat.service.session.ClusteredSessionValve.handleRequest(ClusteredSessionValve.java:135)
          at org.jboss.web.tomcat.service.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:94)
          at org.jboss.web.tomcat.service.session.LockingValve.invoke(LockingValve.java:62)
          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
          at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
          at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
          at java.lang.Thread.run(Thread.java:662)

       

      What's interesting is the MBean has definitely been started prior to the Servlet being loaded.

       

      This used to work fine under JBoss 4.2, 4.0, and possibly even 3.2.

       

      Maybe what's happening is that JBoss 5 doesn't register the MBean until the EAR is fully deployed.

       

      What must I do to wrangle the EAR/SAR/WAR deployment to register the MBean before initing the Servlet?