Search code examples
javawildflymessage-driven-beanjca

MDB Listener for inbound JCA adapter doesn't start in WildFly


Does somebody managed to deploy in WildFly (9.0.2 or 10.0) a MDB bean which listening for standalone JCA adapter?

I've just created an inbound JCA adapter (using ironjacamar-1.2.6) and deployed it on WildFly. Like this:

@Activation(messageListeners = { foo.TestMessageListener.class })
public class TestActivationSpec implements ActivationSpec
...

Next, I added a simple connection (using jboss-cli):

/profile=full-ha/subsystem=resource-adapters/resource-adapter=testRA:add(archive=test.rar,transaction-support=NoTransaction)
/profile=full-ha/subsystem=resource-adapters/resource-adapter=testRA/connection-definitions=TestManagedConnectionFactory:add(class-name=foo.TestManagedConnectionFactory,jndi-name=java:/eis/TestConnectionFactory_ha)

Pretty simple till now. After that, I created WAR application with a target consumer for the Adapter:

@MessageDriven(
    activationConfig = {
            @ActivationConfigProperty(propertyName = "someProperty",
                    propertyValue = "Hi there")}
)
@Vetoed
public class TestServiceConsumer implements TestMessageListener{
...

Here I got my first trouble. This WAR doesn't see TestMessageListener class during deployment (lack of specification support from WildFly, btw). I found a solution by adding a special proprietary descriptor into my WAR archive:

META-INF/jboss-deployment-structure.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="deployment.test.rar" />
        </dependencies>
    </deployment>
</jboss-deployment-structure>

It solves problem with the class loading and my WAR classes became allowed to see RAR interfaces. But now I see other deployment problem:

java.lang.IllegalStateException: WFLYEJB0383: No message listener of type foo.TestMessageListener found in resource adapter activemq-ra

So, the question is why WildFly looks only into its own RA for the listener interface and not into my? Is there are any other specific descriptor to solve this?

Needs to say, that I've played with adding ra.xml descriptior into RAR archive, adding @ActivationConfigProperty to specify the exact RA connection factory (destinationLookup and connectionFactoryLookup). Nothing helps.

My adapter is also implemented an Outbound processing and it works as specified.

Thanks for any advice.


Solution

  • Yes! There is a special descriptor to make it work at WildFly:

    jboss-ejb3.xml

    <?xml version="1.1" encoding="UTF-8"?>
    <jboss:ejb-jar xmlns:jboss="http://www.jboss.com/xml/ns/javaee"
               xmlns="http://java.sun.com/xml/ns/javaee"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:r="urn:resource-adapter-binding"
               xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee    http://www.jboss.org/j2ee/schema/jboss-ejb3-2_0.xsd http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
               version="3.1"
               impl-version="2.0">
        <assembly-descriptor>
            <r:resource-adapter-binding>
                <ejb-name>TestServiceConsumer</ejb-name>
                <r:resource-adapter-name>test.rar</r:resource-adapter-name>
            </r:resource-adapter-binding>
        </assembly-descriptor>
    </jboss:ejb-jar>
    

    But it doesn't work without another one, which should be placed into RAR archive and define some DEFAULT managed connection!

    META-INF/ironjacamar.xml

    <ironjacamar xmlns="http://www.ironjacamar.org/doc/schema"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://www.ironjacamar.org/doc/schema 
             http://www.ironjacamar.org/doc/schema/ironjacamar_1_1.xsd">
    
        <transaction-support>NoTransaction</transaction-support>
    
        <connection-definitions>
            <connection-definition class-name="foo.TestManagedConnectionFactory" jndi-name="java:/eis/TestConnectionFactory" pool-name="TestConnectionFactory">
            </connection-definition>
        </connection-definitions>
    
    </ironjacamar>
    

    Why do we need all these J2EE specs if there are so much pain and arcane knowledge to make them work?!