Reputation: 277
when im trying to send a mail using java mail api in my web application , I'm getting this exception.
java.lang.SecurityException: Access to default session denied
the inputs are fron an html page. then it goes to a servlet which eventually calls a java class where the mail logic is written
Upvotes: 25
Views: 38293
Reputation: 670
I've got the same error, when I launch 2 tests in Webdriver. In secound test i've got "java.lang.SecurityException: Access to default session denied".
When I used method Session.getInstance instead Session.getDefaultInstance in every test, errors disappeared.
Upvotes: 10
Reputation: 14763
This error text is associated with a call to Session.getDefaultInstance(props, authenticator)
where the default instance already has a different authenticator set.
It should work better if you call Session.getInstance(props, authenticator)
instead of Session.getDefaultInstance(props, authenticator)
in your code.
Upvotes: 88