You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Neal Sanche <ne...@nsdev.org> on 2005/08/22 04:47:19 UTC

JavaMail

Hey Guys,

I'm doing some research into a JavaMail and Geronimo tutorial. I noticed 
some rumbling about a JavaMail portlet in the new console, and a bunch 
of old rumbling about problems with the Sun licence on the JavaMail RI. 
Any directions to places in the Source code that would illuminate me, or 
contact with people who are working with the mail APIs in Geronimo would 
be excellent! Thanks all!

Cheers.

-Neal

Re: JavaMail

Posted by Neal Sanche <ne...@nsdev.org>.
Jeremy Boynes wrote:

> Neal Sanche wrote:
>
>>
>> Well, I've looked through the source and found the 
>> org.apache.geronimo.mail module. It seems to contain a few GBeans and 
>> some tests. The tests are mostly empty. How would I create an SMTP 
>> transport session from my code?
>>
>
> Chatting with Geir earlier today it appears our SMTP provider is not 
> being included in the distribution. For now I would suggest modifying 
> the j2ee-server-plan.xml to include Sun's distribution of JavaMail as 
> a dependency *before* the geronimo-spec-j2ee-1.0-M4.jar dependency.
>
> -- 
> Jeremy

Yes, I had figured that there was something missing when my deployment 
did the following:

22:30:40,484 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:269)
        at 
org.apache.geronimo.deployment.service.ServiceConfigBuilder.addGBeans
(ServiceConfigBuilder.java:264)
        at 
org.openejb.deployment.OpenEJBModuleBuilder.addGBeans(OpenEJBModuleBu
ilder.java:372)

Okay, so I've added mail.jar and activation.jar to a sun/jars/ directory 
in my geronimo repository and have also edited the j2ee-server-plan.xml 
that I found in the docs/plans directory to add the following lines:

    <dependency>
      <uri>sun/jars/activation.jar</uri>
    </dependency>
    <dependency>
      <uri>sun/jars/mail.jar</uri>
    </dependency>

But, again I have a feeling that this is not sufficient. I still get the 
same error. Should I be editing the j2ee-server-plan.xml in my 'source 
code' directory and recompiling the server to make this change?

-Neal

Re: JavaMail

Posted by Antonio Gallardo <ag...@agssa.net>.
Geir Magnusson Jr. wrote:

>
> On Aug 23, 2005, at 10:37 PM, Antonio Gallardo wrote:
>
>> Jeremy Boynes wrote:
>>
>>
>>> Neal Sanche wrote:
>>>
>>>
>>>>
>>>> Well, I've looked through the source and found the  
>>>> org.apache.geronimo.mail module. It seems to contain a few GBeans  
>>>> and some tests. The tests are mostly empty. How would I create an  
>>>> SMTP transport session from my code?
>>>>
>>>>
>>>
>>> Chatting with Geir earlier today it appears our SMTP provider is  
>>> not being included in the distribution. For now I would suggest  
>>> modifying the j2ee-server-plan.xml to include Sun's distribution  of 
>>> JavaMail as a dependency *before* the geronimo-spec-j2ee-1.0- M4.jar 
>>> dependency.
>>>
>>
>> Can I do this for another Apache project (Cocoon)? I will like to  
>> add the fixed geronimo-spec-j2ee-1.0-M4.jar into cocoon distro. Are  
>> there some legal concerns?
>
>
> With using geronimo?  No.
>
> With distributing Sun's binary licensed software?  yes :)

:-) Well, I am not going to distribute the Sun's binary code. I know I 
cannot do that. ;-)

I just want to build concretly geronimo-spec-javamail-1.3.1-rc5.jar with 
the above suggested patch. I believe the generated jar will not include 
Sun's binary code. I believe, the code is going to link to the Sun's 
binary code of the javamail.jar.

Given this facts, can I include the geronimo-spec-javamail-1.3.1-rc5.jar 
into the Apache Cocoon distro?

TIA. :-)

Best Regards,

Antonio Gallardo


Re: JavaMail

Posted by "Geir Magnusson Jr." <ge...@apache.org>.
On Aug 23, 2005, at 10:37 PM, Antonio Gallardo wrote:

> Jeremy Boynes wrote:
>
>
>> Neal Sanche wrote:
>>
>>
>>>
>>> Well, I've looked through the source and found the  
>>> org.apache.geronimo.mail module. It seems to contain a few GBeans  
>>> and some tests. The tests are mostly empty. How would I create an  
>>> SMTP transport session from my code?
>>>
>>>
>>
>> Chatting with Geir earlier today it appears our SMTP provider is  
>> not being included in the distribution. For now I would suggest  
>> modifying the j2ee-server-plan.xml to include Sun's distribution  
>> of JavaMail as a dependency *before* the geronimo-spec-j2ee-1.0- 
>> M4.jar dependency.
>>
>
> Can I do this for another Apache project (Cocoon)? I will like to  
> add the fixed geronimo-spec-j2ee-1.0-M4.jar into cocoon distro. Are  
> there some legal concerns?

With using geronimo?  No.

With distributing Sun's binary licensed software?  yes :)

geir

>
> Best Regards,
>
> Antonio Gallardo
>
>

-- 
Geir Magnusson Jr                                  +1-203-665-6437
geirm@apache.org



Re: JavaMail

Posted by Antonio Gallardo <an...@apache.org>.
Jeremy Boynes wrote:

> Neal Sanche wrote:
>
>>
>> Well, I've looked through the source and found the 
>> org.apache.geronimo.mail module. It seems to contain a few GBeans and 
>> some tests. The tests are mostly empty. How would I create an SMTP 
>> transport session from my code?
>>
>
> Chatting with Geir earlier today it appears our SMTP provider is not 
> being included in the distribution. For now I would suggest modifying 
> the j2ee-server-plan.xml to include Sun's distribution of JavaMail as 
> a dependency *before* the geronimo-spec-j2ee-1.0-M4.jar dependency.

Can I do this for another Apache project (Cocoon)? I will like to add 
the fixed geronimo-spec-j2ee-1.0-M4.jar into cocoon distro. Are there 
some legal concerns?

Best Regards,

Antonio Gallardo


Re: JavaMail

Posted by Jeremy Boynes <jb...@apache.org>.
Neal Sanche wrote:
> 
> Well, I've looked through the source and found the 
> org.apache.geronimo.mail module. It seems to contain a few GBeans and 
> some tests. The tests are mostly empty. How would I create an SMTP 
> transport session from my code?
> 

Chatting with Geir earlier today it appears our SMTP provider is not 
being included in the distribution. For now I would suggest modifying 
the j2ee-server-plan.xml to include Sun's distribution of JavaMail as a 
dependency *before* the geronimo-spec-j2ee-1.0-M4.jar dependency.

--
Jeremy

Re: JavaMail

Posted by Jeremy Boynes <jb...@apache.org>.
Neal Sanche wrote:
<snip/>

> 
> Which is all good. Now, which deployment plan do I add the resource ref 
> to? 

You added it to ejb-jar.xml which as you say is good. That is the 
standardized part of the configuration

> I loked for gbean in the schemas and found that it can live in the 
> geronimo-application.xml under my module definitions. Is that the 
> correct place to put it in order to use it from within a SLSB?
> 

The entry in the ejb-jar.xml is declaring that the SLSB is using a mail 
resource. The <gbean> entry is defining what the resource is and is 
allowing you to set its properties; this is vendor specific.

If you are using an EAR to contain the ejb-jar the application 
deployment plan is the place to add it; if you have a naked ejb-jar then 
you should add the GBean definition at the bottom of the ejb deployment 
plan (openejb-jar.xml IIRC). Note these do not need to be included in 
the module archive, the deployer can take a generic module with just 
standard definitions and an external deployment plan.

You can also package up the GBean definition separately using a 
<configuration> plan and deploy that completely separately (perhaps to 
share between multiple applications).

--
Jeremy

Re: JavaMail

Posted by Neal Sanche <ne...@nsdev.org>.
Neal Sanche wrote:

> Jeremy Boynes wrote:
>
>> Neal Sanche wrote:
>>
>>>
>>> Well, I've looked through the source and found the 
>>> org.apache.geronimo.mail module. It seems to contain a few GBeans 
>>> and some tests. The tests are mostly empty. How would I create an 
>>> SMTP transport session from my code?
>>>
>>
>> The easiest way is to define a resource reference in the standard 
>> deployment descriptor:
>>
>>   <resource-ref>
>>     <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>
>>
>> You can then look up the resource with code like:
>>
>>     javax.mail.Session sess = (Session)
>>        new InitialContext().lookup("java:comp/env/mail/MailSession");
>>
>> We don't provide a default session but you can define one using a 
>> GBean in your deployment plan:
>>
>>     <gbean name="mail/MailSession"
>>       class="org.apache.geronimo.mail.SMTPTransportGBean">
>>         <attribute name="host">mail.example.com</attribute>
>>     </gbean>
>>
>> Other attributes can be set as appropriate; I think we support all 
>> the "standard" mail.smtp ones and non-standard ones can be set 
>> through the "properties" attribute.
>
>
> Okay, so, since I'm a bit of an XDoclet nut, still, I've done the 
> following to add the resource ref to one of my SLSB beans:
>
> @ejb.resource-ref
>   description="JavaMail Resource"
>   res-ref-name="mail/MailSession"
>   res-type="javax.mail.Session"
>   res-auth="Container"
>   res-sharing-scope="Shareable"
>
>
> Which ends up adding the following lines to my ejb-jar.xml file:
>
>         <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>
>
> Which is all good. Now, which deployment plan do I add the resource 
> ref to? I loked for gbean in the schemas and found that it can live in 
> the geronimo-application.xml under my module definitions. Is that the 
> correct place to put it in order to use it from within a SLSB?
>
> Thanks Jeremy,
>
> -Neal

Further to this, I am getting the following errors while deploying:

org.apache.geronimo.common.DeploymentException: Unable to resolve 
resource refer
ence 'mail/MailSession' (no matching resources found)
        at 
org.apache.geronimo.naming.deployment.ENCConfigBuilder.addResourceRef
s(ENCConfigBuilder.java:206)
        at 
org.apache.geronimo.naming.deployment.ENCConfigBuilder.buildComponent
Context(ENCConfigBuilder.java:705)
        at 
org.openejb.deployment.SessionBuilder.processEnvironmentRefs(SessionB
uilder.java:167)
        at 
org.openejb.deployment.SessionBuilder.addEJBContainerGBean(SessionBui
lder.java:296)
        at 
org.openejb.deployment.SessionBuilder.buildBeans(SessionBuilder.java:
182)

I'll keep looking... probably I need to add the gbean in the 
openejb-jar.xml deployment plan instead?

-Neal

Re: JavaMail

Posted by Neal Sanche <ne...@nsdev.org>.
Jeremy Boynes wrote:

> Neal Sanche wrote:
>
>>
>> Well, I've looked through the source and found the 
>> org.apache.geronimo.mail module. It seems to contain a few GBeans and 
>> some tests. The tests are mostly empty. How would I create an SMTP 
>> transport session from my code?
>>
>
> The easiest way is to define a resource reference in the standard 
> deployment descriptor:
>
>   <resource-ref>
>     <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>
>
> You can then look up the resource with code like:
>
>     javax.mail.Session sess = (Session)
>        new InitialContext().lookup("java:comp/env/mail/MailSession");
>
> We don't provide a default session but you can define one using a 
> GBean in your deployment plan:
>
>     <gbean name="mail/MailSession"
>       class="org.apache.geronimo.mail.SMTPTransportGBean">
>         <attribute name="host">mail.example.com</attribute>
>     </gbean>
>
> Other attributes can be set as appropriate; I think we support all the 
> "standard" mail.smtp ones and non-standard ones can be set through the 
> "properties" attribute.

Okay, so, since I'm a bit of an XDoclet nut, still, I've done the 
following to add the resource ref to one of my SLSB beans:

 @ejb.resource-ref
   description="JavaMail Resource"
   res-ref-name="mail/MailSession"
   res-type="javax.mail.Session"
   res-auth="Container"
   res-sharing-scope="Shareable"


Which ends up adding the following lines to my ejb-jar.xml file:

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

Which is all good. Now, which deployment plan do I add the resource ref 
to? I loked for gbean in the schemas and found that it can live in the 
geronimo-application.xml under my module definitions. Is that the 
correct place to put it in order to use it from within a SLSB?

Thanks Jeremy,

-Neal

Re: JavaMail

Posted by Jeremy Boynes <jb...@apache.org>.
Neal Sanche wrote:
> 
> Well, I've looked through the source and found the 
> org.apache.geronimo.mail module. It seems to contain a few GBeans and 
> some tests. The tests are mostly empty. How would I create an SMTP 
> transport session from my code?
> 

The easiest way is to define a resource reference in the standard 
deployment descriptor:

   <resource-ref>
     <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>

You can then look up the resource with code like:

     javax.mail.Session sess = (Session)
        new InitialContext().lookup("java:comp/env/mail/MailSession");

We don't provide a default session but you can define one using a GBean 
in your deployment plan:

     <gbean name="mail/MailSession"
       class="org.apache.geronimo.mail.SMTPTransportGBean">
         <attribute name="host">mail.example.com</attribute>
     </gbean>

Other attributes can be set as appropriate; I think we support all the 
"standard" mail.smtp ones and non-standard ones can be set through the 
"properties" attribute.

--
Jeremy

Re: JavaMail

Posted by Neal Sanche <ne...@nsdev.org>.
Jeremy Boynes wrote:

> Neal Sanche wrote:
>
>> Hey Guys,
>>
>> I'm doing some research into a JavaMail and Geronimo tutorial. I 
>> noticed some rumbling about a JavaMail portlet in the new console, 
>> and a bunch of old rumbling about problems with the Sun licence on 
>> the JavaMail RI. Any directions to places in the Source code that 
>> would illuminate me, or contact with people who are working with the 
>> mail APIs in Geronimo would be excellent! Thanks all!
>>
>
> Sure - what questions do you have?

Hi Jeremy,

Well, I've looked through the source and found the 
org.apache.geronimo.mail module. It seems to contain a few GBeans and 
some tests. The tests are mostly empty. How would I create an SMTP 
transport session from my code?

Thanks.

-Neal

Re: JavaMail

Posted by Jeremy Boynes <jb...@apache.org>.
Neal Sanche wrote:
> Hey Guys,
> 
> I'm doing some research into a JavaMail and Geronimo tutorial. I noticed 
> some rumbling about a JavaMail portlet in the new console, and a bunch 
> of old rumbling about problems with the Sun licence on the JavaMail RI. 
> Any directions to places in the Source code that would illuminate me, or 
> contact with people who are working with the mail APIs in Geronimo would 
> be excellent! Thanks all!
> 

Sure - what questions do you have?
--
Jeremy