ubuntu 8.04 LTS 解决tomcat 5.5启动后第一次访问总是会报一个access denied的问题
2010-01-19 14:50
错误提示:
java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.org.apache.coyote)
java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
java.security.AccessController.checkPermission(AccessController.java:546)
java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:1512)
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:298)
java.lang.ClassLoader.loadClass(ClassLoader.java:296)
java.lang.ClassLoader.loadClass(ClassLoader.java:296)
java.lang.ClassLoader.loadClass(ClassLoader.java:248)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
org.apache.coyote.http11.InternalOutputBuffer.sendStatus(InternalOutputBuffer.java:452)
org.apache.coyote.http11.Http11Processor.prepareResponse(Http11Processor.java:1617)
org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:967)
org.apache.coyote.Response.action(Response.java:181)
org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.java:576)
org.apache.coyote.Response.doWrite(Response.java:560)
org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:361)
org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:323)
org.apache.tomcat.util.buf.IntermediateOutputStream.write(C2BConverter.java:236)
sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:272)
sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:276)
sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:122)
java.io.OutputStreamWriter.flush(OutputStreamWriter.java:212)
org.apache.tomcat.util.buf.WriteConvertor.flush(C2BConverter.java:185)
org.apache.tomcat.util.buf.C2BConverter.flushBuffer(C2BConverter.java:128)
org.apache.catalina.connector.OutputBuffer.realWriteChars(OutputBuffer.java:536)
org.apache.tomcat.util.buf.CharChunk.append(CharChunk.java:256)
org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:456)
org.apache.catalina.connector.CoyoteWriter.write(CoyoteWriter.java:143)
org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:119)
org.apache.jasper.runtime.JspWriterImpl.write(JspWriterImpl.java:326)
org.apache.jasper.runtime.JspWriterImpl.write(JspWriterImpl.java:342)
org.apache.jsp.index_jsp._jspService(index_jsp.java:50)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
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:244)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)
头次知道tomcat里面还有policy.d的配置,废了半天时间到处查资料才解决。
修改/etc/tomcat/policy.d/03catalina.policy文件,修改如下:
grant codeBase "file:${catalina.home}/bin/tomcat-juli.jar" {
permission java.security.AllPermission;
};
修改/etc/tomcat/policy.d/04webapps.policy,增加如下两行:
grant {
...........
permission java.lang.RuntimePermission "accessClassInPackage.org.apache.coyote"; permission java.util.PropertyPermission "org.apache.coyote.USE_CUSTOM_STATUS_MSG_IN_HEADER", "read";
..........
};
如果碰到你的servlet有些特殊权限要求,可以在50user.policy文件里面增加:
grant codeBase "file:/var/lib/tomcat5.5/webapps/your_application_path/-" { permission java.security.AllPermission; };
|
http://hi.baidu.com/wqwuhtml/blog/item/d5fc40389fa9832fb9998ffe.html