org.apache.jasper.JasperException:java.security.AccessControlException:拒绝访问(java.net.SocketPermission smtp.gmail.com resolve)

时间:2015-08-11 15:47:44

标签: tomcat7

首先我在Netbeans Glassfish中运行这个jsp文件,一切正常但是当我在tomcat 7在线服务器上运行.war时,它会在尝试发送邮件时抛出此异常:

exception
org.apache.jasper.JasperException: java.security.AccessControlException: access denied (java.net.SocketPermission smtp.gmail.com resolve)
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:274)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:271)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:306)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:166)

root cause
java.security.AccessControlException: access denied (java.net.SocketPermission smtp.gmail.com resolve)
java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
java.security.AccessController.checkPermission(AccessController.java:546)
java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
java.lang.SecurityManager.checkConnect(SecurityManager.java:1031)
java.net.InetAddress.getAllByName0(InetAddress.java:1145)
java.net.InetAddress.getAllByName(InetAddress.java:1083)
java.net.InetAddress.getAllByName(InetAddress.java:1019)
java.net.InetAddress.getByName(InetAddress.java:969)
javax.mail.URLName.getHostAddress(URLName.java:444)
javax.mail.URLName.hashCode(URLName.java:420)
java.util.Hashtable.get(Hashtable.java:334)
javax.mail.Session.getPasswordAuthentication(Session.java:789)
javax.mail.Service.connect(Service.java:216)
javax.mail.Service.connect(Service.java:134)
javax.mail.Service.connect(Service.java:86)
com.sun.mail.smtp.SMTPTransport.connect(SMTPTransport.java:95)
javax.mail.Transport.send0(Transport.java:162)
javax.mail.Transport.send(Transport.java:80)
org.apache.jsp.xoxoxo_jsp._jspService(xoxoxo_jsp.java:120)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:274)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:271)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:306)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:166)

0 个答案:

没有答案