File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Mail Sending troubleshooting

 
Shounak Kundu
Ranch Hand
Posts: 60
IBM DB2 Eclipse IDE Fedora
  • 0
  • Mark post as helpful
  • send pies
  • 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 ?


 
Paul Clapham
Sheriff
Pie
Posts: 20171
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And here is my modified MailSend class :



 
Shounak Kundu
Ranch Hand
Posts: 60
IBM DB2 Eclipse IDE Fedora
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone help me please ?

This problem is seriously driving me nuts....
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 1
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using IBM WebSphere Community Edition as my server. Any idea , how to disable security manager in it ?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic