File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes Java Mail Sending troubleshooting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java Mail Sending troubleshooting" Watch "Java Mail Sending troubleshooting" New topic
Author

Java Mail Sending troubleshooting

Shounak Kundu
Ranch Hand

Joined: Jul 29, 2010
Posts: 60

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 ?



Shounak
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

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

Joined: Jul 29, 2010
Posts: 60

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

Joined: Jul 29, 2010
Posts: 60




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

How to resolve that ?
Shounak Kundu
Ranch Hand

Joined: Jul 29, 2010
Posts: 60

All I want to do is to Authenticate my email username and password only once....

Shounak Kundu
Ranch Hand

Joined: Jul 29, 2010
Posts: 60

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

Joined: Jul 29, 2010
Posts: 60

And here is my modified MailSend class :



Shounak Kundu
Ranch Hand

Joined: Jul 29, 2010
Posts: 60

Can anyone help me please ?

This problem is seriously driving me nuts....
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42913
    
  68
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

Joined: Jul 29, 2010
Posts: 60

I am using IBM WebSphere Community Edition as my server. Any idea , how to disable security manager in it ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Mail Sending troubleshooting