• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Mail Sending troubleshooting

 
Ranch Hand
Posts: 60
IBM DB2 Eclipse IDE Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's my code :




This code is working fine. But , as the session object is initialized every time this class is called, it is generating a SecurityException sometimes.


How can I overcome this ?

In short , how can I check

this portion has been called before or not ?


 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By setting a boolean variable to true after that code is called, and checking if that variable is true before calling that code?
 
Shounak Kundu
Ranch Hand
Posts: 60
IBM DB2 Eclipse IDE Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I want to check if the session instance has been created earlier or not.

If not , then call the method of Session.getDefaultInstance();

else

destroy the session and call it.


How can I end a session ....
 
Shounak Kundu
Ranch Hand
Posts: 60
IBM DB2 Eclipse IDE Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



But the MimeMessage object is complaining that the session object is unreachable...

How to resolve that ?
 
Shounak Kundu
Ranch Hand
Posts: 60
IBM DB2 Eclipse IDE Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All I want to do is to Authenticate my email username and password only once....

 
Shounak Kundu
Ranch Hand
Posts: 60
IBM DB2 Eclipse IDE Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more thing :

I don't why it is happening. When I am trying to call the MailSend class from a JSP page it is showing exception. But , if call the same MailSend class from a Java program , it is not showing any exception.

Why is it happening ?


I am giving you both the JSP page and the Plain Java class.



Here is the content of testmail.jsp :





And the stacktrace while running testMail.jsp




And here is the MailTest2.java , which works perfectly fine:



I am puzzled , can you tell me why this is happening . They are calling the same instance , while one is working fine , another one is generating exception.
 
Shounak Kundu
Ranch Hand
Posts: 60
IBM DB2 Eclipse IDE Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And here is my modified MailSend class :



 
Shounak Kundu
Ranch Hand
Posts: 60
IBM DB2 Eclipse IDE Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone help me please ?

This problem is seriously driving me nuts....
 
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a Security exception - that means the servlet container is running with a security manager enabled that forbids something you're trying to do. Try running the servlet container with a less restrictive security manager (or no security manager at all).

Desktop apps are typically run without a security manager, which is why you don't get the exception there.
 
Shounak Kundu
Ranch Hand
Posts: 60
IBM DB2 Eclipse IDE Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using IBM WebSphere Community Edition as my server. Any idea , how to disable security manager in it ?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic