moty
moty

Reputation: 21

How to send mail via ejb 3.1 annotations based

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 Java EE 6 and understand that I can used in the new Java EE 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 example?

Upvotes: 2

Views: 4456

Answers (1)

Pascal Thivent
Pascal Thivent

Reputation: 570505

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 Java EE 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:

Upvotes: 4

Related Questions