geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: JavaMail Redux
Date Sat, 01 Oct 2005 02:40:42 GMT

On Sep 30, 2005, at 7:19 PM, Neal Sanche wrote:

> Sorry David, I must be extra dense today...
>
> Here's what I understand of the way this works so far:
>
> I have to start a GBean, and I have to make a resource-ref in my  
> Session bean to use it. But I think I'm missing a step. How does  
> Geronimo know which GBean represents a certain resource? Do I also  
> have to make a gbean-ref in my open-ejb.xml deployment plan to make  
> the 'link' somehow? I'm quite confused about this whole area right  
> now, I'm afraid. Is there anyone on the list who's used JavaMail who  
> can point me to example source, or docs? Even a similar situation  
> where a GBean is linked to an SLSB resource-ref would be excellent.

Well, you need to start 2 gbeans: one for the mail session and one for  
the smtp transport.  You only started the transport one, so there was  
no session for the resource-ref to connect to.

All resource-refs (and ejb-refs, except for corba transport) work by  
matching gbean names, which for jsr-77 objects are pretty well  
specified by the jsr-77 spec.  So, from the information you provide,  
namely the name "mail/MailSession" and the type javax.mail.Session we  
start constructing pieces of gbean name to query with.  Mail and JAXR  
are special cases, we notice these types and for mail pick  
j2eeType=JavaMailResource.  You are in a server with domain  
geronimo.server and J2EEServer=geronimo, so we have  
geronimo.server: 
J2EEServer=geronimo,j2eeType=JavaMailResource,name=mail/MailSession,*   
First we look for gbeans matching this pattern in your current  
application, and in your case when you add the missing MailGBean it  
will find that one.  If you leave it out (as at present) it will then  
look for matches in "standalone modules", i.e. with  
J2EEApplication=null.  So, if you added it to a gbean-only plan or  
included it in the o/a/g/Server plan the query would find it.  You can  
always include more info in a resource-ref in the geronimo plan   to  
supply the entire name of the target gbean.

So.... if your plan was:

<application
       xmlns="http://geronimo.apache.org/xml/ns/j2ee/application"
       configId="org/acme/PhoneBook">

    <dependency>
        <uri>geronimo/jars/geronimo-mail-1.0-SNAPSHOT.jar</uri>
    </dependency>        <module>
        <connector>tranql-connector-1.0-SNAPSHOT.rar</connector>
        <alt-dd>mysql-plan.xml</alt-dd>
    </module>

     <gbean name="mail/MailSession"  
class="org.apache.geronimo.mail.MailGBean"/>

      <gbean name="mail/MailSession"
      class="org.apache.geronimo.mail.SMTPTransportGBean">
        <attribute name="host">10.0.0.1</attribute>
        <attribute name="port">25</attribute>
    </gbean>

</application>

the resource ref would be resolved.  The part I don't know is whether  
you need to do something else to tell the mail session to use smtp  
transport or if the fact the transport is initialized will  
automatically register it with the mail session.  I suspect the latter  
but don't know.  This should be covered in standard javamail docs  
however.

Hope this helps,
david jencks

>
> Thanks.
>
> -Neal
>
> David Jencks wrote:
>
>> I'm not the expert on javamail, but...
>>
>> I think you need a MailGBean to be the resource-ref target:
>>
>>     <gbean name="mail/MailSession"   
>> class="org.apache.geronimo.mail.MailGBean"/>
>>
>> I'm not exactly sure what you need to configure so the mail gbean  
>> hooks  up to the smtp protocol bean you already have.
>>
>> Hope this points you a useful direction :-)
>>
>> thanks
>> david jencks
>>
>> On Sep 30, 2005, at 6:24 PM, Neal Sanche wrote:
>>
>>> Hi Guys,
>>>
>>> A long while ago, I asked about getting JavaMail working in  
>>> Geronimo.  Here's what I have done, and the current result:
>>>
>>> My geronimo-application.xml:
>>>
>>> <DEFANGED_application
>>>       xmlns="http://geronimo.apache.org/xml/ns/j2ee/application"
>>>       configId="org/acme/mailverifier">
>>>       <gbean name="mail/MailSession"
>>>    class="org.apache.geronimo.mail.SMTPTransportGBean">
>>>      <attribute name="host">mail.example.com</attribute>
>>>  </gbean>
>>>
>>> </application>
>>>
>>> A resource-ref in a session bean that looks like:
>>>
>>>         <resource-ref >
>>>            <description><![CDATA[JavaMail Resource]]></description>
>>>            <res-ref-name>mail/MailSession</res-ref-name>
>>>            <res-type>javax.mail.Session</res-type>
>>>            <res-auth>Container</res-auth>
>>>            <res-sharing-scope>Shareable</res-sharing-scope>
>>>         </resource-ref>
>>>
>>> I've edited the j2ee-server-plan.xml to add:
>>>
>>>    <dependency>
>>>      <uri>javamail/jars/activation.jar</uri>
>>>    </dependency>
>>>    <dependency>
>>>      <uri>javamail/jars/mail.jar</uri>
>>>    </dependency>
>>>
>>>    <dependency>
>>>      <uri>geronimo/jars/geronimo-mail-1.0-SNAPSHOT.jar</uri>
>>>    </dependency>
>>>
>>> But I get the following error:
>>>
>>> 18:08:16,044 ERROR [Deployer] Deployment failed due to
>>> org.apache.geronimo.gbean.InvalidConfigurationException: Could not   
>>> load class or
>>> g.apache.geronimo.mail.SMTPTransportGBean
>>>        at   
>>> org.apache.geronimo.gbean.GBeanInfo.getGBeanInfo(GBeanInfo.java:56)
>>>        at   
>>> org.apache.geronimo.deployment.service.ServiceConfigBuilder.addGBeanD
>>> ata(ServiceConfigBuilder.java:293)
>>>        at   
>>> org.apache.geronimo.deployment.service.ServiceConfigBuilder.addGBeans
>>> (ServiceConfigBuilder.java:288)
>>>        at   
>>> org.apache.geronimo.j2ee.deployment.EARConfigBuilder.buildConfigurati
>>> on(EARConfigBuilder.java:339)
>>>        at   
>>> org.apache.geronimo.j2ee.deployment.EARConfigBuilder$$FastClassByCGLI
>>> B$$38e56ec6.invoke(<generated>)
>>>        at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
>>>        at   
>>> org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethod
>>> Invoker.java:38)
>>>
>>> If I change my geronimo-application.xml to:
>>>
>>> <DEFANGED_application
>>>       xmlns="http://geronimo.apache.org/xml/ns/j2ee/application"
>>>       configId="org/acme/PhoneBook">
>>>
>>>    <dependency>
>>>        <uri>geronimo/jars/geronimo-mail-1.0-SNAPSHOT.jar</uri>
>>>    </dependency>        <module>
>>>        <connector>tranql-connector-1.0-SNAPSHOT.rar</connector>
>>>        <alt-dd>mysql-plan.xml</alt-dd>
>>>    </module>
>>>      <gbean name="mail/MailSession"
>>>      class="org.apache.geronimo.mail.SMTPTransportGBean">
>>>        <attribute name="host">10.0.0.1</attribute>
>>>        <attribute name="port">25</attribute>
>>>    </gbean>
>>> </application>
>>>
>>> That error goes away, but I'm left with:
>>>
>>> Deployer operation failed: Unable to resolve resource reference   
>>> 'mail/MailSession' (no matching resources found)
>>> org.apache.geronimo.common.DeploymentException: Unable to resolve   
>>> resource reference 'mail/MailSession' (no matching resources found)
>>>    at   
>>> org.apache.geronimo.naming.deployment.ENCConfigBuilder.addResourceRef 
>>> s( ENCConfigBuilder.java:231)
>>>    at   
>>> org.apache.geronimo.naming.deployment.ENCConfigBuilder.buildComponent 
>>> Co ntext(ENCConfigBuilder.java:764)
>>>    at   
>>> org.openejb.deployment.SessionBuilder.processEnvironmentRefs(SessionB 
>>> ui lder.java:167)
>>>    at   
>>> org.openejb.deployment.SessionBuilder.addEJBContainerGBean(SessionBui 
>>> ld er.java:296)
>>>    at   
>>> org.openejb.deployment.SessionBuilder.buildBeans(SessionBuilder.java: 
>>>  182)
>>>    at   
>>> org.openejb.deployment.OpenEJBModuleBuilder.addGBeans(OpenEJBModuleBu 
>>> il der.java:514)
>>>    at   
>>> org.openejb.deployment.OpenEJBModuleBuilder$$FastClassByCGLIB$$11bd7b 
>>> 20 .invoke(<generated>)
>>>    at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
>>>
>>> Any ideas of what I'm doing wrong?
>>>
>>> Thanks.
>>>
>>> -Neal
>>>
>>>
>


Mime
View raw message