views:

61

answers:

1

Hi All!

I am trying to inject javax.mail.session in ejb 3.1 via @Resource without any success, I believe that I miss understood the proper configurations (I want annotations based solution and not XML descriptor)

I read in the new spec of JEE 6 and understand that I can used in the new JEE 6 Connector API to send mails via Message Driven Bean and annotations based solutions, but there is no sample that include the end to end solution... :(

Somebody can help me to understood/have an exmaple? :)

Thanks!

+2  A: 

I am trying to inject javax.mail.session in ejb 3.1 via @Resource without any success, I believe that I miss understood the proper configurations (I want annotations based solution and not XML descriptor)

Actually, using @Resource for JavaMail is not something new in EJB 3.1, it was already possible with Java EE 5 and is covered in the The confirmer Example Application of the Java EE 5 Tutorial, including the application server configuration part (yes, this part is application server specific).

For GlassFish v3 (you didn't mention it but I'm assuming you're using GFv3), see:


Thanks! But there is no mention about the solution of JEE 6 Connector API with annotations configuration (smtp host + username + password + protocol and etc)...? Did you know on that topic? Thanks!

Honestly, I'm not sure to understand what you're trying to do exactly. You're talking about using JCA to send emails via a MDB, using annotations. This is confusing, at least for me. You should maybe include some links pointing to the things you saw, include some context information.

That being said, if your question is actually how to write a custom JCA mail resource adapter, maybe the following article will help:

Pascal Thivent
Thanks!But there is no mention about the solution of JEE 6 Connector API with annotations configuration (smtp host + username + password + protocol and etc)...?Did you know on that topic?Thanks!
moty
To back up Pascal here, '@Resource javax.mail.Session' is how you get a mail session used for *sending* mail from any EJB. JavaMail support has been required since at least J2EE 1.4. No connector is required for this. The configuration of that Session is vendor-specific. There is no standard way to *receive* mail via an MDB, though that is possible via custom Connector (I'm not aware of an existing one). This blog post gives some insight on how connectors and MDBs relate if you are interested in writing a custom connector http://bit.ly/9pxk5F+
David Blevins