4 Replies Latest reply on Feb 21, 2014 1:44 PM by Troy Bronzan

    Need help deploying ear with a resource adapter in it

    Troy Bronzan Newbie

      I am having difficulties getting a resource adapter working.  The resource adapter is inside an EAR file.  I've tried looking around for examples of resource adapters but nothing seems to be working.  I'm migrating the application from glassfish to wildfly and it works in glassfish so there's something I'm missing in the configuration

       

      {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.deployment.subunit.\"pbx.ear\".\"ejb-pbx.jar\".component.PbxRecordListenerEJB.CREATE is missing [jboss.ra.pbx#ra]"]}

       

      standalone.xml

       

      <resource-adapter id="pbx#ra">
        <archive>pbx#ra.rar</archive>
        <transaction-support>NoTransaction</transaction-support>
        <connection-definitions>
             <connection-definition class-name="com.foo.ra.api.CollectorConnectionFactory" jndi-name="java:jboss/pbxra/CollectorConnectionFactory" enabled="true" pool-name="foora">
                  <security>
                       <application/>
                  </security>
                  <validation>
                       <background-validation>false</background-validation>
                  </validation>
             </connection-definition>
        </connection-definitions>
      </resource-adapter>
      

       

      ra.xml (deployment descriptor in ra project)

       

      <?xml version="1.0" encoding="UTF-8"?>
      <connector id="Connector_ID" version="1.5" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"> 
        <description>Experimental foo Collector adapter</description>
        <display-name>foo-ra</display-name>
        <vendor-name>foo</vendor-name>
        <eis-type>PBX data</eis-type>
        <resourceadapter-version>0.1</resourceadapter-version>                                  
        <resourceadapter>
             <resourceadapter-class>com.foo.ra.ResourceAdapterImpl</resourceadapter-class>
             <outbound-resourceadapter>
                  <connection-definition>
                       <managedconnectionfactory-class>com.foo.ra.outbound.ManagedConnectionFactoryImpl</managedconnectionfactory-class>
                       <connectionfactory-interface>com.foo.ra.api.CollectorConnectionFactory</connectionfactory-interface>
                       <connectionfactory-impl-class>com.foo.ra.outbound.CollectorConnectionFactoryImpl</connectionfactory-impl-class>
                       <connection-interface>com.foo.ra.api.CollectorConnection</connection-interface>
                       <connection-impl-class>com.foo.ra.outbound.CollectorConnectionImpl</connection-impl-class>
                  </connection-definition>
                  <transaction-support>NoTransaction</transaction-support>
                  <reauthentication-support>false</reauthentication-support>
             </outbound-resourceadapter>
             <inbound-resourceadapter>
                  <messageadapter>
                       <messagelistener>
                            <messagelistener-type>com.foo.ra.api.PbxRecordListener</messagelistener-type>
                            <activationspec>
                                 <activationspec-class>com.foo.ra.inbound.ActivationSpecImpl</activationspec-class>
                            </activationspec>
                       </messagelistener>
                  </messageadapter>
             </inbound-resourceadapter>  
        </resourceadapter>
      </connector>
      

       

      mdb

       

      @MessageDriven(messageListenerInterface = PbxRecordListener.class)
      @ResourceAdapter(value = "pbx#ra.rar")
      public class PbxRecordListenerEJB implements PbxRecordListener
      {
        ...
      }
      
        • 1. Re: Need help deploying ear with a resource adapter in it
          Greg Jewell Novice

          I had a similar issue, but with JBoss AS 7.1.1.  I had to make two minor changes to the annotation in the MDB.

           

          First, I had to use the JBoss-specific @ResourceAdapter annotation (org.jboss.ejb3.annotation.ResourceAdapter), and the value had to include the name of the ear itself.  So:

           

          @org.jboss.ejb3.annotation.ResourceAdapter(value="pbx.ear#ra.rar")

           

          I don't have any experience with Wildfly, though, and don't know whether that particular annotation still exists.

          1 of 1 people found this helpful
          • 2. Re: Need help deploying ear with a resource adapter in it
            Troy Bronzan Newbie

            Thanks for the response.  I modified the annotation as suggested and used ironjacamar to generate the <resource-adapter> to be used in standalone.xml.  Here's the new version.

             

            <resource-adapter id="pbx.ear#ra.rar">
                <archive>pbx.ear#ra.rar</archive>
                <transaction-support>NoTransaction</transaction-support>
                <connection-definitions>
                   <connection-definition class-name="com.foo.ra.outbound.ManagedConnectionFactoryImpl" jndi-name="java:jboss/eis/CollectorConnection" enabled="true" use-java-context="true" pool-name="CollectorConnection" use-ccm="true">
                        <pool>
                             <min-pool-size>0</min-pool-size>
                             <max-pool-size>10</max-pool-size>
                             <prefill>false</prefill>
                             <use-strict-min>false</use-strict-min>
                             <flush-strategy>FailingConnectionOnly</flush-strategy>
                      </pool>
                      <security>
                        <application/>
                      </security>
                  </connection-definition>
                </connection-definitions>
            </resource-adapter>
            
            

             

             

            This gets me further.  The error is now a CNFE for the MDB.  The RAR is deployed in an EAR and the ejb-pbx.jar that has the PbxRecordListener is in the lib folder of the EAR.

             

            "{\"JBAS014671: Failed services\" => {\"jboss.deployment.subunit.\\\"pbx.ear\\\".\\\"ejb-pbx.jar\\\".component.PbxRecordListenerEJB.CREATE\" => \"org.jboss.msc.service.StartException in service jboss.deployment.subunit.\\\"pbx.ear\\\".\\\"ejb-pbx.jar\\\".component.PbxRecordListenerEJB.CREATE: Failed to start service
                Caused by: java.lang.RuntimeException: java.lang.InstantiationException: Unable to create representation
                Caused by: java.lang.InstantiationException: Unable to create representation
                Caused by: java.lang.ClassNotFoundException: com.foo.ra.api.PbxRecordListener from [Module \\\"deployment.pbx.ear.ra.rar:main\\\" from Service Module Loader]\"}}"
            
            
            • 3. Re: Need help deploying ear with a resource adapter in it
              Greg Jewell Novice

              Add an entry into your application.xml stating that the ejb-pbx.jar is an ejb module.

               

              <module>
              <ejb>ejb-pbx.jar</ejb>
              </module>

               

              Also move that jar from the lib directory into the root of the ear.

              • 4. Re: Re: Need help deploying ear with a resource adapter in it
                Troy Bronzan Newbie

                Sorry my configuration information in my post above was wrong.  My application.xml is set up that way, but it made me double check the ra.xml and I noticed that


                <messagelistener-type>com.foo.ra.api.PbxRecordListener</messagelistener-type>
                
                


                is incorrect in ra.xml  and should really be


                <messagelistener-type>com.foo.ejb.message.PbxRecordListener</messagelistener-type>

                 

                After I made that change, the ear file deploys.  I have a bunch of exceptions now but at least I finally got it deployed.  Thanks to everyone for their help.