Failed to link a MDB to an inbound resource adapter on Wildfly 10.x - deployment failed

1.5k views Asked by At

I progammed an simple tcp inbound resource adapter (RA) as an example project on github and deployed it successful to wildfly 10.x with standalone-full configuration. The message listener TcpMessageListener interface is located in the RA and defined in the ra.xml descriptor, but I can't connect a message driven bean (MDB) to it. The eis side of the RA works as expected, I can connect/send messages with telnet to it. When I try to deploy the MDB with the wildfly maven plugin, the MDB couldn't find the TcpMessageListener and I got java.lang.NoClassDefFoundError:

WARN  [org.jboss.modules] (MSC service thread 1-7) Failed to define class de.bitc.ejb.InboundEventHandler in Module "deployment.ra-ear.ear.ra-user-ejb-0.0.1-SNAPSHOT.jar:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link de/bitc/ejb/InboundEventHandler (Module "deployment.ra-ear.ear.ra-user-ejb-0.0.1-SNAPSHOT.jar:main" from Service Module Loader): de/bitc/jca/inflow/TcpMessageListener
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  .
  .
  .
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service jboss.deployment.subunit."ra-ear.ear"."ra-user-ejb-0.0.1-SNAPSHOT.jar".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."ra-ear.ear"."ra-user-ejb-0.0.1-SNAPSHOT.jar".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment "ra-user-ejb-0.0.1-SNAPSHOT.jar" of deployment "ra-ear.ear"
  .
  .
  .
Caused by: java.lang.NoClassDefFoundError: Failed to link de/bitc/ejb/InboundEventHandler (Module "deployment.ra-ear.ear.ra-user-ejb-0.0.1-SNAPSHOT.jar:main" from Service Module Loader): de/bitc/jca/inflow/TcpMessageListener
  .
  .
  .
ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 17) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "ra-ear.ear")]) - failure description: {
"WFLYCTL0080: Failed services" => {"jboss.deployment.subunit.\"ra-ear.ear\".\"ra-user-ejb-0.0.1-SNAPSHOT.jar\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"ra-ear.ear\".\"ra-user-ejb-0.0.1-SNAPSHOT.jar\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment \"ra-user-ejb-0.0.1-SNAPSHOT.jar\" of deployment \"ra-ear.ear\"
Caused by: java.lang.NoClassDefFoundError: Failed to link de/bitc/ejb/InboundEventHandler (Module \"deployment.ra-ear.ear.ra-user-ejb-0.0.1-SNAPSHOT.jar:main\" from Service Module Loader): de/bitc/jca/inflow/TcpMessageListener"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.subunit.\"ra-ear.ear\".\"ra-user-ejb-0.0.1-SNAPSHOT.jar\".POST_MODULE"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined

The dependency in the ejb maven submodule is in the provided scope. I followed with the deployment of the RA the redhat guide. I also switched in the ejb submodule the maven dependency of the resource adapter from provided to compile. In this case I got the following errors

[ERROR] Caused by: java.lang.IllegalStateException: WFLYEJB0383: No message listener of type de.bitc.jca.inflow.TcpMessageListener found in resource adapter tcp-eis.rar"},
  "WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.subunit.\"ra-ear.ear\".\"ra-user-ejb-0.0.1-SNAPSHOT.jar \".component.InboundEventHandler.CREATE"],
  "WFLYCTL0180: Services with missing/unavailable dependencies" => undefined}}}

Here is the MDB

package de.bitc.ejb;

import java.util.logging.Logger;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;

import org.jboss.ejb3.annotation.ResourceAdapter;

import de.bitc.jca.inflow.TcpMessageListener;

@MessageDriven(
    activationConfig = {
            @ActivationConfigProperty(propertyName = "topic",  propertyValue = "test")
        } //, messageListenerInterface = TcpMessageListener.class
        )
@ResourceAdapter(value="tcp-eis.rar")
public class InboundEventHandler implements TcpMessageListener {

    /** The logger */
    private static Logger log = Logger.getLogger(InboundEventHandler.class.getName());

    /**
     * Default constructor.
     */
    public InboundEventHandler() {
        // TODO Auto-generated constructor stub
    }

    /**
     * @see TcpMessageListener#onMessage(String)
     */
    @Override
    public void onMessage(String msg) {
        // TODO Auto-generated method stub
    }
}

Here is the TcpListenerInterface

package de.bitc.jca.inflow;

/**
 * TcpMessageListener
 *
 * @version $Revision: $ 
 */
public interface TcpMessageListener {
    /**
     * Receive message
     * 
     * @param msg
     *            String.
     */
    public void onMessage(String msg);
}

Here are the settings of the resource adapter in the jboss_cli

 /subsystem=resource-adapters/resource-adapter=tcp-eis.rar:read-resource(recursive=true)
{
    outcome => success,
    result => {
        archive => tcp-eis.rar,
        beanvalidationgroups => undefined,
        bootstrap-context => undefined,
        config-properties => undefined,
        module => undefined,
        statistics-enabled => false,
        transaction-support => XATransaction,
        wm-security => false,
        wm-security-default-groups => undefined,
        wm-security-default-principal => undefined,
        wm-security-domain => other,
        wm-security-mapping-groups => undefined,
        wm-security-mapping-required => false,
        wm-security-mapping-users => undefined,
        admin-objects => undefined,
        connection-definitions => undefined
    }
}

My question is, is there a missing step in the deployment that a MDB find the resource adapter. I think this is done with the @ResourceAdapter annotation? Did I need to define a queue or something? The resources about inbound resouce adapters are very rare and the most examples are outbound resource adapters. Thanks in advance.

The above linked inbound-ra-example is hosted on github. I described all steps to build and run it in the README.md in the github project. I want to host these example for others which have the same problems to find documentation.

1

There are 1 answers

0
Jochen Buchholz On BEST ANSWER

I solved the class loading NoClassDefFoundError: Failed to link error and the now running example answers many open questions. I put all details to my example. The inbound resource adapter runs now as a sub-deployment in an ear archive on wildfly 10 (WF10). I generated the inbound resource adapter with the IronJacamar codegenerator. I described all steps how build and run in the example.

The main mistakes where, I did not use the jboss-deployment-structure descriptor in the ear archive and a maven dependency to the resource adapter api in the ear archive. I put the dependency into the ear while testing and forgot it.

<?xml version="1.0" encoding="UTF-8"?>  
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">  
    <ear-subdeployments-isolated>false</ear-subdeployments-isolated>  
    <sub-deployment name="ra-user-ejb.jar">  
        <dependencies>  
            <module name="deployment.ra-ear.ear.tcp-eis.rar"  export="true" />  
        </dependencies>  
    </sub-deployment>  
</jboss-deployment-structure>

Here are my biggest ear embedded inbound RA answers to solve the documentation leak a little bit:

  • The ra.xml descriptor is not needed, the @Connector annotation in the RA class is enough.
  • There is no additional configuration in WF10 needed. No queues, standallone-full.xml modification or jndi stuff. A simple deploy with the wildfly-maven-plugin works.
  • The now working resource adapter is not showing up as resource adapter in WF10. This confuses me and make my research very difficult.
  • The jboss-ejb3.xml descriptor is not needed. The @ResourceAdapter(value="ra-ear.ear#tcp-eis.rar") is enough. Take care, this is a jboss annotation, not an ee7. So you not find any resources in case of eg. websphere or tomee.

I will extend the example resource adapter in the next days to a full ee7 app and hope that this example help others on the way through the inbound resource adapter documentation hell.