wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes javax.mail.session and DataSource(Apache Tomcat) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "javax.mail.session and DataSource(Apache Tomcat)" Watch "javax.mail.session and DataSource(Apache Tomcat)" New topic
Author

javax.mail.session and DataSource(Apache Tomcat)

Sergey Kargopolov
Ranch Hand

Joined: Jul 04, 2003
Posts: 63
Good day!

I am trying to set up DataSource to use javax.mail.session. And I need help here.

1.I think I configured web.xml correctly.

<resource-ref>
<res-ref-name>mail/MailSession</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

2. How to lookup JNDI is also clear I think

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
Session session = (javax.mail.Session) envCtx.lookup("mail/MailSession");

3. But I am not sure how to configure server.xml(TOMCAT)

<Resource name="mail/MailSession" auth="Container" ype="javax.mail.Session" mail.smtp.host="sergey"/>

Is it correct way to configure?

Please suggest me where can I go and read more information about java.mail.session with DataSource, may be see some examples, tutorials.


Thank you very much!
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

A javax.mail.Session is nothing to do with a javax.sql.DataSource. You've given your resource reference the wrong type.

Your resource factory configuration looks ok though, assuming you have an SMTP host set up called 'sergey'?

(By the way, we have a Tomcat forum which is specifically for these kinds of configuration questions. Next time you would be better posting there).


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Sergey Kargopolov
Ranch Hand

Joined: Jul 04, 2003
Posts: 63
I am very sorry I have misstyped it!!!

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

Thank you for your reply
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

No need to apologise! Don't feel worried about posting code with mistakes in it on JavaRanch; we all do it and helping with the mistakes is what we are for.
Sergey Kargopolov
Ranch Hand

Joined: Jul 04, 2003
Posts: 63
Paul, thank you for your replies.
The problems was not because of above misspelling.

I am not sure now to create Resource in Tomcat server.xml

<Resource name="mail/MailSession" auth="Container" ype="javax.mail.Session" mail.smtp.host="sergey"/>

sergey - is server name(my local machine)

I have written a very simple web client that sends ands receives emails. Now I am re-designing its architecture and i want Sessions or even Store connections to be managed by Container. For that I am trying to configure Datasource. But if I modify my Tomcat server.xml in the way I posted above, tomcat stops working .

I have posted a message to Tomcat forum after you have suggested me to do that. Hopefully, with your help and with the help of others I will manage to solve my problem.

Thank you very much Paul!
Sergey Kargopolov
Ranch Hand

Joined: Jul 04, 2003
Posts: 63
I got it working!

http://www.coderanch.com/t/86121/Tomcat/javax-mail-Session-DataSource-Apache


Thank you!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax.mail.session and DataSource(Apache Tomcat)
 
Similar Threads
Retrieve resource of deployment descriptor
Name bound to Context
javax.mail.Session and DataSource (Apache Tomcat)
javax.mail.Session and DataSource (Apache Tomcat)
How to re-config "mail.host.smtp","localhost" in tomcat 5.0.28