3 Replies Latest reply on Mar 9, 2016 11:16 AM by jfisherdev

    WildFly 9.0.2 MBean Data Source Dependencies

    jfisherdev Apprentice

      I am currently in the process of migrating a suite of enterprise applications from JBoss AS 4.2.2 to WildFly 9.0.2.


      With assistance from ctomc, I recently addressed an issue with a small EAR application [called DataSourceManager] that dynamically configures data sources via JMX operations on deployment/startup with an MBean causing deadlocks in the deployment process. The issue and the application/deployment are described in further detail here: WildFly 9.0.2 MBean Start Method Timeout/Deadlock


      The solution to the issue was to execute the JMX operations for data source configuration on a separate thread from the deployment thread. While this does address the deadlock issue, there is now an issue with  MBeans in other applications in the suite attempting to access data sources, which are configured by the DataSourceManager application deployment process, during startup before the DataSourceManager has finished the data source configuration process.


      There are two things I am looking to do, neither of which I am exactly sure how to do.


      1. Ensure that the DataSourceManager EAR is always deployed first before other applications in the suite. The rest of the applications in the suite essentially relies on the DataSourceManager being deployed prior to them being deployed. In JBoss AS 4.2.2, the way that this appears to have been accomplished was by adding an "EnhancedSuffixes" attribute to the ear-deployer.xml configuration file like this:


           <mbean code="org.jboss.deployment.EARDeployer"
                <attribute name="EnhancedSuffixes">646:DataSourceManager.ear,647:app2.ear,648:app3.ear,649:app4.ear,650:.ear</attribute>


      I am not sure if there is a way to define a global deployment order like this in WildFly 9.0.2.


      2. For applications that access data sources configured by DataSourceManager in MBeans during deployment/startup, ensure that the data sources needed by the application are configured. There are two ways I can think of doing this. One would be creating another MBean in the DataSourceManager application/EAR that is deployed after the main DataSourceManagerMBean that performs the configuration whose responsibility is to check that all data sources have been configured. This would maybe be done by checking if the JMX resource for the data source is registered with the MBeanServer used to configure it [although, based on what was said in the linked discussion, I am not sure if this would cause deadlock issues since it involves a JMX operation] or attempting to lookup the data sources and create connections, waiting/retrying for a finite period of time before throwing an exception. The other would be for each application/MBean to declare dependencies on the data sources it needs, which I am not sure how to do. While applications/MBeans did not do this previously because it was not necessary, I believe in JBoss AS 4.2.2, this could be configured in a jboss-service.xml descriptor like this:


           <mbean code="AppMBean"


      I do not believe that this can be done in WildFly 9.0.2.


      Any information or ideas about this would be very much appreciated.

        • 1. Re: WildFly 9.0.2 MBean Data Source Dependencies
          jfisherdev Apprentice

          I tried implementing the idea I mentioned in the original post of a dependent MBean that waits for the configuration to complete. Unfortunately, that leads to another deadlock issue, as the thread that does the configuration/management operations always runs after the deployment of other applications in the suite is complete.


          I am going to look into a different approach to this issue.


          I would still appreciate any ideas about how to accomplish either of the items I mentioned.

          • 2. Re: WildFly 9.0.2 MBean Data Source Dependencies
            jfisherdev Apprentice

            As far as the inter-deployment dependency and deployment order issue is concerned, it looks like using jboss-all.xml deployment descriptors will work. It provides a proper way to define deployment dependencies and deployment order, as opposed to configuring EAR deployment order in the way that was done in JBoss 4.2.2.


            The second issue with dynamic data sources not being available when applications that depend on them are deploying has not been solved yet.


            I am looking into using extensions to do this, though I have not been successful with this yet. I wrote this post about what I am looking to do with extensions:




            I would still appreciate any ideas about how the second issue, even if it is simply to say whether or not it is possible.

            • 3. Re: WildFly 9.0.2 MBean Data Source Dependencies
              jfisherdev Apprentice

              I was not able to find a way to configure data sources with the DataSourceManager MBean so that the data sources would be available for other applications when they are deployed.


              Instead of using the MBean approach, I eventually found a way to do this with an extension that does the data source configuration using the JBoss DMR and datasources subsystem API when the subsystem provided by my extension is added on startup. This approach seems to be working.


              I will consider this question effectively answered.