我在 SunOS 5.10 上运行 tomcat7,并且正在 webapp/ROOT/ 目录下开发一个 webapp。我正在尝试在应用程序中查看 webapp/foo 目录是否存在:
String invpath = application.getRealPath( "user" ) //I also use this for something else
String soapPath = invpath.substring( 0, invpath.indexOf( "ROOT/user" ) ) + "foo";
out.print(soapPath);
//test if SOAP is installed
File soap = new File( soapPath );
if( soap.exists() ) //this is the line he doesn't like much
{//html code}
但是tomcat抛出了我:
org.apache.jasper.JasperException: An exception occurred processing JSP page /content/home.jsp at line 83
java.security.AccessControlException: access denied ("java.io.FilePermission" "/path/to/tomcat/webapps/foo" "read")
目录的绝对路径是好的。
我确实对该目录中的每个人都具有读取权限,并且当我在 debian 机器上运行此代码时,它运行良好......我几乎不知道 Solaris/SunOS(但我确实很了解 linux),所以我的错误可能非常愚蠢!