How to inject POJO to MBean in SAR application in JBoss EAP 6

Solution Unverified - Updated -

Issue

I would like to inject POJO defined in jboss-beans.xml to mbean defined in jboss-service.xml of SAR application in EAP 6.

The following injecting POJO to MBean by using <inject bean="myTask"/> in jboss-service.xml of SAR works fine in EAP 5:

  • META-INF/jboss-service.xml:

    <server>
      <mbean code="com.redhat.jboss.support.HelloService"
             name="example:type=HelloService,service=Hello">
         <attribute name="Message">Hello!!</attribute>
         <attribute name="Task"><inject bean="myTask"/></attribute>
      </mbean>
    </server>
    
  • META-INF/jboss-beans.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <deployment xmlns="urn:jboss:bean-deployer:2.0">
      <bean name="myTask" class="com.redhat.jboss.support.SimpleTask">
      </bean>
    </deployment>
    

But the same way does not work in EAP 6 with the following ERROR at deployment of SAR:

INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "HelloService.sar"
INFO  [org.jboss.as.osgi] (MSC service thread 1-8) JBAS011907: Register module: Module "deployment.HelloService.sar:main" from Service Module Loader
INFO  [stdout] (MSC service thread 1-4) SimpleTask.create()
INFO  [stdout] (MSC service thread 1-4) SimpleTask.start()
INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS015870: Deploy of deployment "HelloService.sar" was rolled back with failure message {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.mbean.registration.example:type=HelloService,service=Hello Missing[JBAS014861: <one or more transitive dependencies>]","jboss.mbean.service.example:type=HelloService,service=Hello.start Missing[jboss.mbean.service.myTask.start]","jboss.mbean.service.example:type=HelloService,service=Hello.create Missing[jboss.mbean.service.myTask.create]"]}
INFO  [org.jboss.as.osgi] (MSC service thread 1-6) JBAS011908: Unregister module: Module "deployment.HelloService.sar:main" from Service Module Loader
INFO  [stdout] (MSC service thread 1-4) SimpleTask.stop()
INFO  [stdout] (MSC service thread 1-8) SimpleTask.destroy()
INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015877: Stopped deployment HelloService.sar in 40ms
ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.mbean.registration.example:type=HelloService,service=Hello Missing[JBAS014861: <one or more transitive dependencies>]","jboss.mbean.service.example:type=HelloService,service=Hello.start Missing[jboss.mbean.service.myTask.start]","jboss.mbean.service.example:type=HelloService,service=Hello.create Missing[jboss.mbean.service.myTask.create]"]}}}

How do I achieve same thing in EAP 6? The attached HelloService-EAP6-inject-reproducer.tar.gz is a reproducer.

Environment

  • JBoss Enterprise Application Platform (EAP)
    • 6.0.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content