6 Replies Latest reply on Aug 19, 2013 9:57 AM by ybxiang.china

    How to use the ironjacamar mail resource adapter

    jodt

      I'm trying to setup a MDB that listens for mail received message for a particular email address. To do this I'm trying to use the ironjacamar mail-1.0.19.Final.rar resource adapter. Unfortunately, I don't know how to configure JBoss AS 7.2 (EAP 6.1) to use the resource adapter. Does anyone know how to configure Jboss to use this resource adapter?

       

      I think there are 2 steps:

      1. Setup the mail-1.0.19.Final.rar as a resource adapter in the standalone.xml

      2. Deploy the mail-1.0.19.Final.rar in deployments directory.

       

      Unfortunately I don't know what's needed in the ressource-adapter section of the standalone.xml or if there is any other configuration I need. Any help would be very appreciated.

       

       

       

      Here's the information I get from the rar-info.bat script for the rar.

      Archive:mail-1.0.19.Final.rar
      JCA version:1.5
      Type:
      InBound
      Reauth:
      No
      Compliant:Yes
      Native:
      No

       

       

      Structure:

      ----------

      META-INF/

      META-INF/MANIFEST.MF

      META-INF/ra.xml

      ironjacamar-mail.jar

       

       

      Resource-adapter:

      -----------------

      Class: org.jboss.jca.adapters.mail.MailResourceAdapter

        Config-property: QueueSize (java.lang.Integer)

       

       

      Activation-spec:

      ----------------

      Class: org.jboss.jca.adapters.mail.inflow.MailActivationSpec

        Message-listener: org.jboss.jca.adapters.mail.inflow.MailListener

        Required-config-property: mailServer

        Required-config-property: mailFolder

        Required-config-property: storeProtocol

        Introspected Config-property: debug (java.lang.Boolean)

        Introspected Config-property: flush (java.lang.Boolean)

        Introspected Config-property: maxMessages (java.lang.Integer)

        Introspected Config-property: messageSelector (java.lang.String)

        Introspected Config-property: password (java.lang.String)

        Introspected Config-property: pollingInterval (java.lang.Long)

        Introspected Config-property: port (java.lang.Integer)

        Introspected Config-property: starttls (java.lang.Boolean)

        Introspected Config-property: userName (java.lang.String)

       

       

      META-INF/MANIFEST.MF:

      ---------------------

      Manifest-Version: 1.0

      Ant-Version: Apache Ant 1.8.4

      Created-By: 1.6.0_45-b06 (Sun Microsystems Inc.)

       

       

       

       

      META-INF/ra.xml:

      ----------------

      <?xml version="1.0" encoding="UTF-8"?>

       

       

      <!-- $Id: ra.xml 71556 2008-04-01 13:39:35Z adrian@jboss.org $ -->

       

       

      <connector 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"

                 version="1.5">

       

       

        <description>JBoss JavaMail Resource Adapter</description>

        <display-name>JavaMail Adapter</display-name>

       

        <vendor-name>Red Hat Middleware LLC</vendor-name>

        <eis-type>JavaMail Adapter</eis-type>

        <resourceadapter-version>7.0</resourceadapter-version>

       

       

        <license>

          <description>

      JBoss, Home of Professional Open Source.

      Copyright 2011, Red Hat Middleware LLC, and individual contributors

      as indicated by the @author tags. See the copyright.txt file in the

      distribution for a full listing of individual contributors.

       

       

      This is free software; you can redistribute it and/or modify it

      under the terms of the GNU Lesser General Public License as

      published by the Free Software Foundation; either version 2.1 of

      the License, or (at your option) any later version.

       

       

      This software is distributed in the hope that it will be useful,

      but WITHOUT ANY WARRANTY; without even the implied warranty of

      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU

      Lesser General Public License for more details.

       

       

      You should have received a copy of the GNU Lesser General Public

      License along with this software; if not, write to the Free

      Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA

      02110-1301 USA, or see the FSF site: http://www.fsf.org.

          </description>

          <license-required>true</license-required>

        </license>

       

       

        <resourceadapter>

          <resourceadapter-class>org.jboss.jca.adapters.mail.MailResourceAdapter</resourceadapter-class>

          <config-property>

            <config-property-name>QueueSize</config-property-name>

            <config-property-type>java.lang.Integer</config-property-type>

            <config-property-value>1024</config-property-value>

          </config-property>

       

       

          <inbound-resourceadapter>

            <messageadapter>       

              <messagelistener>

                <messagelistener-type>org.jboss.jca.adapters.mail.inflow.MailListener</messagelistener-type>

                <activationspec>

                  <activationspec-class>org.jboss.jca.adapters.mail.inflow.MailActivationSpec</activationspec-class>

                  <required-config-property>

                    <config-property-name>mailServer</config-property-name>

                  </required-config-property>

                  <required-config-property>

                    <config-property-name>mailFolder</config-property-name>

                  </required-config-property>

                  <required-config-property>

                    <config-property-name>storeProtocol</config-property-name>

                  </required-config-property>

                </activationspec>

              </messagelistener>

            </messageadapter>

          </inbound-resourceadapter>

       

       

        </resourceadapter>

       

       

      </connector>

       

       

      Deployment descriptor:

      ----------------------

      <?xml version="1.0" encoding="UTF-8" standalone="no"?>

      <resource-adapters>

        <resource-adapter>

          <archive>mail-1.0.19.Final.rar</archive>

          <config-property name="QueueSize">1024</config-property>

          <transaction-support>NoTransaction</transaction-support>

        </resource-adapter>

      </resource-adapters>

        • 1. Re: How to use the ironjacamar mail resource adapter
          nd_100

          My debugging findings explained below...  I have attached a debugger screenshot that shows what I have described below.

           

          In org.jboss.as.ejb3.component.EJBUtilities.createActivationSpecs() method, there is an "Class.equals" comparison of the expected MailListener interface, and available listeners for a given resource adapter.  The "Class.equals" defaults to "==" i.e. unless both operands are NOT the same INSTANCE, the result is false).  In this case, the comparison of two Class objects (org.jboss.jca.adapters.mail.inflow.MailListener) fails...  This leads to an exception being thrown, and hence the mail listener mdb isn't instantiated.  The two class objects of this same class are created during the startup process i.e. one when the mail-rar resource adapter is deployed, and another when the mdb instantiates...

           

          Naively, it seems to me that instead of Class.equals() comparison, it should be a isAssignableFrom() or a instance-of comparison.  Since Class itself is a final class, i can't override the equals method (not that I think its a good idea to begin with).

          Any pointers?

           

          Nav

          • 2. Re: How to use the ironjacamar mail resource adapter
            nd_100

            Resolution: To address the issue I listed in post above, I made the following changes to the rar (mail-1.0.19.Final.rar):

             

            1. Extracted and deployed the ironjacamar-mail.jar (contained within the rar) as a jboss module under modules/org/jboss/ironjacamar/mail/main (module.xml attached along)
            2. Removed all classes from the ironjacamar-mail.jar contained within the rar(mail-1.0.19.Final.rar) except org.jboss.jca.adapters.mail.MailResourceAdapter.class.  The classes we removed from the jar have already been deployed in step 1 as a module.

             

            At this point, we are able to deploy the updated rar file (from step 2), and instantiate a mdb that can listen to emails without any errors...

            • 3. Re: How to use the ironjacamar mail resource adapter
              ybxiang.china
              • 4. Re: How to use the ironjacamar mail resource adapter
                ybxiang.china

                I think there are 2 steps:

                1. Setup the mail-1.0.19.Final.rar as a resource adapter in the standalone.xml

                2. Deploy the mail-1.0.19.Final.rar in deployments directory.

                ~~~~~~~~ You are on the wrong way. Both of those steps are NOT needed. You just need to write some XML elements in standalone.xml or module.xml. JavaMail module has been integrated into JBoss AS 7.

                 

                NOTE, you had better use JBoss AS 7.2.0, there maybe some bugs in jboss as 7.1.0.

                • 5. Re: How to use the ironjacamar mail resource adapter
                  nd_100

                  Hmm..  Thanks for the info on javamail being part of as7, I ll look into it.  Appreciate it!

                  • 6. Re: How to use the ironjacamar mail resource adapter
                    ybxiang.china