发送邮件发生错误:java.lang.SecurityException: Access to default session denied

summergray 2003-08-22 08:42:57
请问有人知道是什么原因吗?

应该和代码没问题,因为在另一台服务器上发送邮件是成功的,可转移了台服务器就出现了这个问题,而且两台发物器的平台是一样的,请问应该是那里的设置问题呢?
...全文
1096 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
summergray 2003-08-23
  • 打赏
  • 举报
回复
是同一个程序在不同的程序服务器用同一个smtp服务器发送邮件,在一个程序服务器上可以,在另一个程序服务器上不可以
summergray 2003-08-22
  • 打赏
  • 举报
回复
是 请求获得邮件会话对象 就没有权限了
summergray 2003-08-22
  • 打赏
  • 举报
回复
是在用到
session = Session.getDefaultInstance(props, new Email_Autherticatorbean( user, password ) );

带身份验证的邮件要用到的一个类
的时候
Sundery 2003-08-22
  • 打赏
  • 举报
回复
既然物理平台一样,显然是不是应用程序服务器的密码或者是数据库的密码不对吧?
hesi726 2003-08-22
  • 打赏
  • 举报
回复
只不知道是在哪一句抛出的异常??
cshchina 2003-08-22
  • 打赏
  • 举报
回复
是在同一个程序的不同地方用两个smtp服务器发邮件的么?
如果是请用Session.getInstance(props,auth)
否则会得到同一个对象
getDefaultInstance
public static Session getDefaultInstance(java.util.Properties props,
Authenticator authenticator)
Get the default Session object. If a default has not yet been setup, a new Session object is created and installed as the default.
Since the default session is potentially available to all code executing in the same Java virtual machine, and the session can contain security sensitive information such as user names and passwords, access to the default session is restricted. The Authenticator object, which must be created by the caller, is used indirectly to check access permission. The Authenticator object passed in when the session is created is compared with the Authenticator object passed in to subsequent requests to get the default session. If both objects are the same, or are from the same ClassLoader, the request is allowed. Otherwise, it is denied.

Note that if the Authenticator object used to create the session is null, anyone can get the default session by passing in null.

In JDK 1.2, additional security Permission objects may be used to control access to the default session.

Parameters:
props - Properties object. Used only if a new Session object is created.
It is expected that the client supplies values for the properties listed in Appendix A of the JavaMail spec (particularly mail.store.protocol, mail.transport.protocol, mail.host, mail.user, and mail.from) as the defaults are unlikely to work in all cases.
authenticator - Authenticator object. Used only if a new Session object is created. Otherwise, it must match the Authenticator used to create the Session.
Returns:
the default Session object

summergray 2003-08-22
  • 打赏
  • 举报
回复
一样的错误,是不能

请求获得邮件会话对象
lotofu 2003-08-22
  • 打赏
  • 举报
回复
先不要验证好了,
session = Session.getDefaultInstance(props, null);

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧