3 Replies Latest reply on Mar 13, 2014 8:11 AM by Jozef Hartinger

    Get BeanManager instance form WildFly extension

    czerny Newbie

      Hi,

      I'm developing tool for inspection of CDI bean relations. I wonder how to get an instance of javax.enterprise.inject.spi.BeanManager of some application in WildFly extension, particularly in org.jboss.as.server.deployment.DeploymentUnitProcessor#deploy.

      Thanks for advices.

      Jakub

        • 2. Re: Re: Get BeanManager instance form WildFly extension
          czerny Newbie

          What exactly means to

          add a dependency to this service

          ?

          I've tried to add line

          <module name="org.jboss.as.weld" />
          

          in module descriptror (module.xml) dependencies. This cause

          serviceRegistry.getService(WeldBootstrapService.SERVICE_NAME)
          

          to return null. If I added

          <module name="org.jboss.as.weld" services="import"/>
          

          into module.xml instead, WildFly failed to boot with exception

          02:02:00,092 ERROR [org.jboss.as.server] (Controller Boot Thread) JBAS015956: Caught exception during boot: org.jboss.as.controller.persistence.ConfigurationPersistenceException: JBAS014676: Failed to parse configuration

              at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:112) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]

              at org.jboss.as.server.ServerService.boot(ServerService.java:331) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]

              at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:256) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]

              at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]

          Caused by: javax.xml.stream.XMLStreamException: JBAS014674: Failed to load module org.jboss.as.weld

              at org.jboss.as.controller.parsing.ExtensionXml.parseExtensions(ExtensionXml.java:155) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]

              at org.jboss.as.server.parsing.StandaloneXml.readServerElement_1_4(StandaloneXml.java:434) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]

              at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:145) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]

              at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:107) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]

              at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.1.0.Final.jar:1.1.0.Final]

              at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69) [staxmapper-1.1.0.Final.jar:1.1.0.Final]

              at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:104) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]

              ... 3 more

          Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: JBAS014817: A subsystem named 'weld' cannot be registered by extension 'org.jboss.as.weld' -- a subsystem with that name has already been registered by extension 'com.acme.corp.tracker'.

              at java.util.concurrent.FutureTask.report(FutureTask.java:122) [rt.jar:1.7.0_51]

              at java.util.concurrent.FutureTask.get(FutureTask.java:188) [rt.jar:1.7.0_51]

              at org.jboss.as.controller.parsing.ExtensionXml.parseExtensions(ExtensionXml.java:147) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]

              ... 9 more

          Caused by: java.lang.IllegalStateException: JBAS014817: A subsystem named 'weld' cannot be registered by extension 'org.jboss.as.weld' -- a subsystem with that name has already been registered by extension 'com.acme.corp.tracker'.

              at org.jboss.as.controller.extension.ExtensionRegistry.checkNewSubystem(ExtensionRegistry.java:404) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]

              at org.jboss.as.controller.extension.ExtensionRegistry.access$1300(ExtensionRegistry.java:98) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]

              at org.jboss.as.controller.extension.ExtensionRegistry$ExtensionInfo.getSubsystemInfo(ExtensionRegistry.java:734) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]

              at org.jboss.as.controller.extension.ExtensionRegistry$ExtensionInfo.access$1100(ExtensionRegistry.java:721) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]

              at org.jboss.as.controller.extension.ExtensionRegistry$ExtensionParsingContextImpl.setSubsystemXmlMapping(ExtensionRegistry.java:475) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]

              at org.jboss.as.weld.WeldExtension.initializeParsers(WeldExtension.java:93)

              at org.jboss.as.controller.parsing.ExtensionXml.loadModule(ExtensionXml.java:183) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]

              at org.jboss.as.controller.parsing.ExtensionXml.access$000(ExtensionXml.java:69) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]

              at org.jboss.as.controller.parsing.ExtensionXml$1.call(ExtensionXml.java:127) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]

              at org.jboss.as.controller.parsing.ExtensionXml$1.call(ExtensionXml.java:124) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]

              at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_51]

              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]

              at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]

              at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final.jar:2.1.1.Final]

           

          02:02:00,105 FATAL [org.jboss.as.server] (Controller Boot Thread) JBAS015957: Server boot has failed in an unrecoverable manner; exiting. See previous messages for details.

           

          Deployment processor is executed in phase Phase.POST_MODULE with priority Phase.POST_MODULE_UNDERTOW_HANDLERS = 12032 [0x2f00].

          WildFly 8.0.0.Final

           

          Thank you for any ideas.

          • 3. Re: Re: Get BeanManager instance form WildFly extension
            Jozef Hartinger Master

            You need to define your own service that will have a dependency on WeldBootstrapService. A dependency is a MSC construct - see http://docs.jboss.org/jbossmsc/latest/api/org/jboss/msc/service/ServiceBuilder.html

             

            Here is an example of WeldStartService that is registered and specifies a dependency on WeldBootstrapService: https://github.com/wildfly/wildfly/blob/master/weld/src/main/java/org/jboss/as/weld/deployment/processors/WeldDeploymentProcessor.java#L248