6 Replies Latest reply on Oct 16, 2013 4:42 AM by rhanus

    WebApp WAR to define/deploy MBean through jboss-service.xml

    kaja.mohideen

      HI all,

       

      I'm trying to develop few webapps where one webapp may use services exposed by other webapps. Interface classes for the services are packaged in WEB-INF/lib for each webapp and I don't really want to create jar dependency for the war to be deployed.

       

      What I'm looking for is - each webapp to define few MBeans which exposes the state of services provided by it, so other webapps' MBean can have a dependency on MBeans it uses from the former webapp; to wait & start only after the service provider MBeans starts.

       

      I have searched in web and found that MBeans can be defined in jboss-service.xml in WEB-INF directory of war. But, having that file doesn't make any difference and I don't see the MBean through JMX Console. Is there any configuration I have to do in jboss which will inform jboss to parse & act on this xml file?

       

      Any help is highly appreciated.

       

      regards,

      Kaja

        • 1. Re: WebApp WAR to define/deploy MBean through jboss-service.xml
          pmm

          Are you using EAR packaging? If you have you considered replacing the service mbeans with EJBs and making a "skinny" WARs (moving the inferface JAR to the lib/ folder in the EAR)?

          • 2. Re: WebApp WAR to define/deploy MBean through jboss-service.xml
            kaja.mohideen

            No. Im not packing my war inside ear. What is the best way to do what im trying to do? I know sar can easily achieve this mbean stuff, but im bit skeptical about selecting jboss specific thing. Please suggest best practice.

            • 3. Re: Re: WebApp WAR to define/deploy MBean through jboss-service.xml
              pmm

              There used to be mainly two reasons for having JBoss service MBeans: Having only a single instance and eager stat up. Both can now be solved with an EJB and @Singleton and @Startup. However in order to only get one instance across multiple WARs all the WARs need to be in a single EAR file. In addition the EJB needs to be in an EJB JAR in the EAR (in theory it could also be in a WAR). The service interfaces for the EJB need to be in a JAR in the lib folder of the EAR — it must not be in the WEB-INF/lib folder of any WAR. In addition you can move common JARs between WARs to the lib/ folder in the EAR as well. So an EAR would look like this:

               

              application.ear
              +- service-ejb.jar // the service EJB is here
              +- webapp1.war
              +- webapp2.war
              \- lib/
                 \- service-interface.jar // the service interfaces are here
              

               

              The easiest way to implement this is using a build system like maven and the maven-ear-plugin.

              1 of 1 people found this helpful
              • 4. Re: WebApp WAR to define/deploy MBean through jboss-service.xml
                rhanus

                right   and dependency between ejb singletons can be defined by annotation @DependsOn

                • 5. Re: WebApp WAR to define/deploy MBean through jboss-service.xml
                  kaja.mohideen

                  I have created an ear project and my war is placed inside it as skinny war. But, I don't want to use EJB, due to the fact that I don't really have multiple Interfaces to expose the state of services provided by my webapps. I just have one interface & an implementation; which i'm planning to instantiate with different properties using jboss-service.xml inside my wars.

                   

                  I have included the jboss-service.xml inside WEB-INF/ of my war. But, that mbean is not registered. Do I have to define a jboss-app.xml or anything extra for using my jboss-service.xml & register my mbeans?

                   

                  Thanks & regards,

                  Kaja

                  • 6. Re: WebApp WAR to define/deploy MBean through jboss-service.xml
                    rhanus

                    I just have one interface & an implementation; which i'm planning to instantiate with different properties using jboss-service.xml inside my wars.

                    I would code a CDI bean per war archive implementing your interface along with a qualifier annotation. If you turn off ear subdeployments isolation the container injects any kind of qualified bean from whatever war. Injecting beans resolves your dependencies but you may suffer from circular dependency problem....