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/10/01 03:24:01 UTC
JavaMail Redux
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:
<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:
<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.addResourceRefs(ENCConfigBuilder.java:231)
at
org.apache.geronimo.naming.deployment.ENCConfigBuilder.buildComponentContext(ENCConfigBuilder.java:764)
at
org.openejb.deployment.SessionBuilder.processEnvironmentRefs(SessionBuilder.java:167)
at
org.openejb.deployment.SessionBuilder.addEJBContainerGBean(SessionBuilder.java:296)
at
org.openejb.deployment.SessionBuilder.buildBeans(SessionBuilder.java:182)
at
org.openejb.deployment.OpenEJBModuleBuilder.addGBeans(OpenEJBModuleBuilder.java:514)
at
org.openejb.deployment.OpenEJBModuleBuilder$$FastClassByCGLIB$$11bd7b20.invoke(<generated>)
at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
Any ideas of what I'm doing wrong?
Thanks.
-Neal
Re: JavaMail Redux
Posted by Neal Sanche <ne...@nsdev.org>.
David Jencks wrote:
> I'm very unclear as to what works in your example and what doesn't.
> I'd appreciate clear answers to the following questions:
>
> As a starting point, I'm assuming that you are using the
> configuration in which you have put the sun javamail and activation
> implementations into the classpath before or instead of the geronimo
> ones.
>
> 1. If you remove the attribute
>
>> <attribute name="debug">true</attribute>
>
> completely, can you send and receive mail?
I'm not currently trying to receive mail. If the property is not there,
there seems to be no effect on functionality. Mail will send.
>
> 2. If you include the attribute
>
>> <attribute name="debug">true</attribute>
>
> can you send and receive mail, although there is no debug output?
There is no debug output, mail does send.
>
> 3. If you remove the attribute
>
>> <attribute name="debug">true</attribute>
>
>
> and include an attribute
> <attribute name="properties">mail.debug=true</attribute>
> can you send and receive mail, and is there debug output?
Yes, I can send, and there is debug output!
> There is definitely a bug in the handling of the "debug" attribute,
> but you should be able to work around it by using the properties
> attribute. It is not clear from your post whether including the
> explicit debug attribute results in no mail service or no debug info
> with working mail service.
My biggest problem is that no matter how I try, I cannot get the
mail.smtp.host property to stick. I would think this falls under 'no
mail service', since many people require a connection to an external
smtp server for mail sending to work.
> I have not followed the issues of shipping the sun javamail
> implementation in depth, but I believe that until very recently the
> license definitely prohibited apache from distributing the sun
> implementation and that the license has recently changed to make this
> issue murky.
I understand the license issues. Personally, I don't mind getting
another one, installing it, and using it in a supported way. I'm just
trying to figure out the supported way through trial and error.
Cheers.
-Neal
Re: JavaMail Redux
Posted by David Jencks <da...@yahoo.com>.
I'm very unclear as to what works in your example and what doesn't.
I'd appreciate clear answers to the following questions:
As a starting point, I'm assuming that you are using the configuration
in which you have put the sun javamail and activation implementations
into the classpath before or instead of the geronimo ones.
1. If you remove the attribute
> <attribute name="debug">true</attribute>
completely, can you send and receive mail?
2. If you include the attribute
> <attribute name="debug">true</attribute>
can you send and receive mail, although there is no debug output?
3. If you remove the attribute
> <attribute name="debug">true</attribute>
and include an attribute
<attribute name="properties">mail.debug=true</attribute>
can you send and receive mail, and is there debug output?
There is definitely a bug in the handling of the "debug" attribute, but
you should be able to work around it by using the properties attribute.
It is not clear from your post whether including the explicit debug
attribute results in no mail service or no debug info with working mail
service.
I have not followed the issues of shipping the sun javamail
implementation in depth, but I believe that until very recently the
license definitely prohibited apache from distributing the sun
implementation and that the license has recently changed to make this
issue murky.
Many thanks,
david jencks
On Oct 2, 2005, at 11:00 AM, Neal Sanche wrote:
> Okay All,
>
> I have worked quite a lot on this issue, and will try to explain what
> my current findings are, so that anyone else trying to get JavaMail
> working can avoid the pitfalls. I have tested several versions
> (snapshots, and an M5 release candidate) and can only conclude that
> JavaMail API support isn't complete yet. If it were complete, you
> would be able to do the following:
>
> In your geronimo-application.xml deployment plan add a dependency to
> the Geronimo Mail component:
>
> <dependency>
> <uri>geronimo/jars/geronimo-mail-1.0-M5.jar</uri>
> </dependency>
>
> And Configure two GBeans:
>
> <gbean name="JavaMailProtocol.smtp"
> class="org.apache.geronimo.mail.SMTPTransportGBean">
> <attribute name="host">192.168.10.10</attribute>
> </gbean>
>
> <gbean name="mail/MailSession"
> class="org.apache.geronimo.mail.MailGBean">
> <attribute name="transportProtocol">smtp</attribute>
> <attribute name="useDefault">false</attribute>
> <attribute name="debug">true</attribute>
> <reference
> name="Protocols"><name>JavaMailProtocol.smtp</name></reference>
> </gbean>
>
> Then in a Stateless Session Bean's Object JavaDocs you can put this
> XDoclet tag:
>
> * @ejb.resource-ref description="JavaMail Resource"
> * res-ref-name="mail/MailSession"
> * res-type="javax.mail.Session" res-auth="Container"
> * res-sharing-scope="Shareable"
>
> Or, if you're still using Deployment Descriptors directly, something
> like the following in your ejb-jar.xml would work:
>
> <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>
>
> Okay, so why in the world doesn't this work? Well, there's no actual
> providers available in Geronimo to support the SMTP protocol. So, what
> you end up with is an execption that looks like this:
>
> javax.mail.NoSuchProviderException: Unable to locate provider for
> protocol: smtp
>
> at javax.mail.Session.getProvider(Session.java:225)
> at javax.mail.Session.getTransport(Session.java:331)
> at javax.mail.Session.getTransport(Session.java:320)
>
> What's nice is the Geronimo developers have gone through and
> implemented the javax.mail.Session class and if there were some
> providers available it would be possible to tell Geronimo's Mail API
> about them and have them used. I've confirmed that it would get that
> far, if there were any.
>
> So, why not use the JavaMail reference implementation from Sun? You
> could personally do so, yes, download it, put its jars into the
> Geronimo repository and you'd be able to do just that. Personally I
> downloaded the JavaMail mail.jar and JAF activation.jar and put them
> into repository/javamail/jars/ under my Geronimo server root. Then I
> added the following dependencies before the geronimo-mail dependency
> in my geronimo-application.xml deployment plan like so:
>
> <dependency>
> <uri>javamail/jars/mail.jar</uri>
> </dependency>
>
> <dependency>
> <uri>javamail/jars/activation.jar</uri>
> </dependency>
>
> <dependency>
> <uri>geronimo/jars/geronimo-mail-1.0-M5.jar</uri>
> </dependency>
>
> Now, when I write code like the following in my SLSB bean, it gives me
> a Session and I can use it to get a transport and send mail:
>
> InitialContext ctx = null;
> try {
> ctx = new InitialContext();
>
> javax.mail.Session session =
> (Session)ctx.lookup("java:comp/env/mail/MailSession");
>
> MimeMessage mes = new MimeMessage(session);
> mes.setFrom(InternetAddress.parse("someguy@nsdev.org")[0]);
> mes.setRecipients(RecipientType.TO,"anotherguy@nsdev.org");
> mes.setSubject("Testing");
> mes.setSentDate(new Date());
>
> mes.setContent(body,"text/plain");
> mes.saveChanges();
> Transport transport = session.getTransport();
> transport.connect();
>
> transport.sendMessage(mes,InternetAddress.parse("anotherguy@nsdev.org")
> );
> transport.close();
> } catch (Throwable ex) {
> ex.printStackTrace();
> } finally {
> if (ctx != null) ctx.close();
> }
>
> This looks easy enough. But there are problems with this. What's
> actually happening behind the scenes here is that the $getResource()
> method of the MailGBean is being called to obtain a javax.mail.Session
> instance. MailGBean makes a fairly fatal mistake in how it sets up the
> Session's default Properties, however. Sun's JavaMail will not accept
> any properties that aren't Strings when it goes to parse things. So
> although you can see that I set the attribute 'debug' to 'true' in the
> MailGBean configuration, above, it is actually converted to a Boolean
> object, and that object is put into the properties. And Sun's JavaMail
> ignores it because it's not a String.
>
> So that means that although it's nice to have the MailGBean and
> associated ProtocolGBean subclasses, the way they build the Properties
> for the Session isn't compatible with Sun's JavaMail implementation,
> so you can't use it.
>
> So that leaves me with no alternative, at this time, than to add the
> JavaMail dependencies, and use Sun's JavaMail API directly to obtain
> sessions through the javax.mail.Session.getDefaultInstance() method
> instead of the more typical resource-ref and InitialContext.lookup().
>
> As I say, this is how it is with the current state of Geronimo, days
> before an M5 release. I'm just reporting... I know it'll get fixed up
> soon anyway.
>
> Cheers.
>
> -Neal
>
Re: JavaMail Redux
Posted by Neal Sanche <ne...@nsdev.org>.
Okay All,
I have worked quite a lot on this issue, and will try to explain what my
current findings are, so that anyone else trying to get JavaMail working
can avoid the pitfalls. I have tested several versions (snapshots, and
an M5 release candidate) and can only conclude that JavaMail API support
isn't complete yet. If it were complete, you would be able to do the
following:
In your geronimo-application.xml deployment plan add a dependency to the
Geronimo Mail component:
<dependency>
<uri>geronimo/jars/geronimo-mail-1.0-M5.jar</uri>
</dependency>
And Configure two GBeans:
<gbean name="JavaMailProtocol.smtp"
class="org.apache.geronimo.mail.SMTPTransportGBean">
<attribute name="host">192.168.10.10</attribute>
</gbean>
<gbean name="mail/MailSession"
class="org.apache.geronimo.mail.MailGBean">
<attribute name="transportProtocol">smtp</attribute>
<attribute name="useDefault">false</attribute>
<attribute name="debug">true</attribute>
<reference
name="Protocols"><name>JavaMailProtocol.smtp</name></reference>
</gbean>
Then in a Stateless Session Bean's Object JavaDocs you can put this
XDoclet tag:
* @ejb.resource-ref description="JavaMail Resource"
* res-ref-name="mail/MailSession"
* res-type="javax.mail.Session" res-auth="Container"
* res-sharing-scope="Shareable"
Or, if you're still using Deployment Descriptors directly, something
like the following in your ejb-jar.xml would work:
<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>
Okay, so why in the world doesn't this work? Well, there's no actual
providers available in Geronimo to support the SMTP protocol. So, what
you end up with is an execption that looks like this:
javax.mail.NoSuchProviderException: Unable to locate provider for
protocol: smtp
at javax.mail.Session.getProvider(Session.java:225)
at javax.mail.Session.getTransport(Session.java:331)
at javax.mail.Session.getTransport(Session.java:320)
What's nice is the Geronimo developers have gone through and implemented
the javax.mail.Session class and if there were some providers available
it would be possible to tell Geronimo's Mail API about them and have
them used. I've confirmed that it would get that far, if there were any.
So, why not use the JavaMail reference implementation from Sun? You
could personally do so, yes, download it, put its jars into the Geronimo
repository and you'd be able to do just that. Personally I downloaded
the JavaMail mail.jar and JAF activation.jar and put them into
repository/javamail/jars/ under my Geronimo server root. Then I added
the following dependencies before the geronimo-mail dependency in my
geronimo-application.xml deployment plan like so:
<dependency>
<uri>javamail/jars/mail.jar</uri>
</dependency>
<dependency>
<uri>javamail/jars/activation.jar</uri>
</dependency>
<dependency>
<uri>geronimo/jars/geronimo-mail-1.0-M5.jar</uri>
</dependency>
Now, when I write code like the following in my SLSB bean, it gives me a
Session and I can use it to get a transport and send mail:
InitialContext ctx = null;
try {
ctx = new InitialContext();
javax.mail.Session session =
(Session)ctx.lookup("java:comp/env/mail/MailSession");
MimeMessage mes = new MimeMessage(session);
mes.setFrom(InternetAddress.parse("someguy@nsdev.org")[0]);
mes.setRecipients(RecipientType.TO,"anotherguy@nsdev.org");
mes.setSubject("Testing");
mes.setSentDate(new Date());
mes.setContent(body,"text/plain");
mes.saveChanges();
Transport transport = session.getTransport();
transport.connect();
transport.sendMessage(mes,InternetAddress.parse("anotherguy@nsdev.org"));
transport.close();
} catch (Throwable ex) {
ex.printStackTrace();
} finally {
if (ctx != null) ctx.close();
}
This looks easy enough. But there are problems with this. What's
actually happening behind the scenes here is that the $getResource()
method of the MailGBean is being called to obtain a javax.mail.Session
instance. MailGBean makes a fairly fatal mistake in how it sets up the
Session's default Properties, however. Sun's JavaMail will not accept
any properties that aren't Strings when it goes to parse things. So
although you can see that I set the attribute 'debug' to 'true' in the
MailGBean configuration, above, it is actually converted to a Boolean
object, and that object is put into the properties. And Sun's JavaMail
ignores it because it's not a String.
So that means that although it's nice to have the MailGBean and
associated ProtocolGBean subclasses, the way they build the Properties
for the Session isn't compatible with Sun's JavaMail implementation, so
you can't use it.
So that leaves me with no alternative, at this time, than to add the
JavaMail dependencies, and use Sun's JavaMail API directly to obtain
sessions through the javax.mail.Session.getDefaultInstance() method
instead of the more typical resource-ref and InitialContext.lookup().
As I say, this is how it is with the current state of Geronimo, days
before an M5 release. I'm just reporting... I know it'll get fixed up
soon anyway.
Cheers.
-Neal
Re: JavaMail Redux
Posted by Neal Sanche <ne...@nsdev.org>.
Thanks David,
That's a really great explanation. I have started the two GBeans now.
The code deploys now, and seems to have the beans available. I will try
calling my code to look up a session and see what I get back when I try.
Thanks very much for the help. I'll let you know what I find out.
Cheers.
-Neal
David Jencks wrote:
>
> 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:
>
> <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.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
>>>>
>>>>
>>
Re: JavaMail Redux
Posted by Neal Sanche <ne...@nsdev.org>.
Well, after many hours of trying to figure out what's going on, I have
made little progress.
I am now getting the following exception:
javax.mail.NoSuchProviderException: Unable to locate provider for
protocol: smtp
at javax.mail.Session.getProvider(Session.java:225)
at javax.mail.Session.getTransport(Session.java:331)
at javax.mail.Session.getTransport(Session.java:320)
at
org.acme.mailverifier.ejb.MailVerifierSessionBean.sendValidationEmail
(MailVerifierSessionBean.java:100)
My Gbeans currently look like the following, though I'm certain they are
incorrect.
<gbean name="smtpProtocol"
class="org.apache.geronimo.mail.ProtocolGBean">
<attribute name="host">10.0.0.1</attribute>
<attribute name="protocol">smtp</attribute>
</gbean>
<gbean name="smtpTransport"
class="org.apache.geronimo.mail.SMTPTransportGBean">
<attribute name="host">10.0.0.1</attribute>
<attribute name="port">25</attribute>
</gbean>
<gbean name="mail/MailSession"
class="org.apache.geronimo.mail.MailGBean">
<attribute name="transportProtocol">smtp</attribute>
<attribute name="host">10.0.0.1</attribute>
<attribute name="useDefault">true</attribute>
<attribute name="debug">true</attribute>
</gbean>
The protocol and transport beans are things I was trying, but I'm sure
they're wrong.
I am able to get the javax.mail.Session instances, so that's working.
It's just that Javamail doesn't seem to be making the necessary
associations. I've even tried putting javamail.default.providers files
into META_INF but it doesn't seem to get far with those. I've even set
the Debug flag and it's not outputting any debug information that I can see.
Thanks for any help you can give.
Cheers.
-Neal
David Jencks wrote:
>
> 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:
>
> <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.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
>>>>
>>>>
>>
Re: JavaMail Redux
Posted by David Jencks <da...@yahoo.com>.
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
>>>
>>>
>
Re: JavaMail Redux
Posted by Neal Sanche <ne...@nsdev.org>.
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.
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.addResourceRefs(
>> ENCConfigBuilder.java:231)
>> at
>> org.apache.geronimo.naming.deployment.ENCConfigBuilder.buildComponentCo
>> ntext(ENCConfigBuilder.java:764)
>> at
>> org.openejb.deployment.SessionBuilder.processEnvironmentRefs(SessionBui
>> lder.java:167)
>> at
>> org.openejb.deployment.SessionBuilder.addEJBContainerGBean(SessionBuild
>> er.java:296)
>> at
>> org.openejb.deployment.SessionBuilder.buildBeans(SessionBuilder.java:
>> 182)
>> at
>> org.openejb.deployment.OpenEJBModuleBuilder.addGBeans(OpenEJBModuleBuil
>> der.java:514)
>> at
>> org.openejb.deployment.OpenEJBModuleBuilder$$FastClassByCGLIB$$11bd7b20
>> .invoke(<generated>)
>> at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
>>
>> Any ideas of what I'm doing wrong?
>>
>> Thanks.
>>
>> -Neal
>>
>>
Re: JavaMail Redux
Posted by David Jencks <da...@yahoo.com>.
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:
>
> <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:
>
> <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.addResourceRefs(
> ENCConfigBuilder.java:231)
> at
> org.apache.geronimo.naming.deployment.ENCConfigBuilder.buildComponentCo
> ntext(ENCConfigBuilder.java:764)
> at
> org.openejb.deployment.SessionBuilder.processEnvironmentRefs(SessionBui
> lder.java:167)
> at
> org.openejb.deployment.SessionBuilder.addEJBContainerGBean(SessionBuild
> er.java:296)
> at
> org.openejb.deployment.SessionBuilder.buildBeans(SessionBuilder.java:
> 182)
> at
> org.openejb.deployment.OpenEJBModuleBuilder.addGBeans(OpenEJBModuleBuil
> der.java:514)
> at
> org.openejb.deployment.OpenEJBModuleBuilder$$FastClassByCGLIB$$11bd7b20
> .invoke(<generated>)
> at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
>
> Any ideas of what I'm doing wrong?
>
> Thanks.
>
> -Neal
>
>