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)?
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.
1 of 1 people found this helpful
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
@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.
right and dependency between ejb singletons can be defined by annotation @DependsOn
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,
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....