• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

javax.mail.session and DataSource(Apache Tomcat)

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Sergey Kargopolov
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it working!

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


Thank you!
 
No. No. No. No. Changed my mind. Wanna come down. To see this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic