加载文件 struts-default.xml 时捕获异常
我对 Java 并不陌生。我以前用它做过很多事情。但我正在从 PHP 迁移到 Java Servlet/JSP(我是新手),但我无法找出这个错误来挽救我的生命。我使用 Ubuntu 9.04 的 Synaptic 包管理器安装了 Tomcat6,它的工作方式非常出色。但是当我将 struts 放入 WEB-INF/lib 目录并尝试制作 struts 应用程序时,我在日志文件中得到以下内容。
我使用struts-blank.war来启动项目,因此web.xml与struts 2.1.8.1中提供的相同。
读取 struts-default.xml 文件似乎存在一些问题。
提前致谢
严重:启动过滤器 struts2 时出现异常 无法加载配置。 - 类:java.security.AccessControlContext 文件:AccessControlContext.java 方法:检查权限 行:342-java/security/AccessControlContext.java:342:-1 在 org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:431) 在 org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69) 在 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51) 在 org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275) 在 org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397) 在 org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:108) 在 org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709) 在 org.apache.catalina.core.StandardContext.start(StandardContext.java:4359) 在 org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) 在 org.apache.catalina.core.ContainerBase.access$000(ContainerBase.java:123) 在 org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:145) 在 java.security.AccessController.doPrivileged(本机方法) 在 org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:769) 在 org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) 在 org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926) 在 org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889) 在 org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492) 在 org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149) 在 org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) 在 org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) 在 org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) 在 org.apache.catalina.core.StandardHost.start(StandardHost.java:719) 在 org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) 在 org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) 在 org.apache.catalina.core.StandardService.start(StandardService.java:516) 在 org.apache.catalina.core.StandardServer.start(StandardServer.java:710) 在 org.apache.catalina.startup.Catalina.start(Catalina.java:578) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:616) 在 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:616) 在 org.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:177) 原因:无法加载配置。 - 类:java.security.AccessControlContext 文件:AccessControlContext.java 方法:检查权限 行:342-java/security/AccessControlContext.java:342:-1 在 com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58) 在org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374) 在 org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418) ... 36 更多 原因:加载文件 struts-default.xml 时捕获异常 - 类:java.security.AccessControlContext 文件:AccessControlContext.java 方法:检查权限 行:342-java/security/AccessControlContext.java:342:-1 在 com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:902) 在 com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:143) 在 com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:110) 在 com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:168) 在 com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55) ... 38 更多 引起原因:java.security.AccessControlException:访问被拒绝(java.util.PropertyPermission xwork.saxParserFactory 读取) 在 java.security.AccessControlContext.checkPermission(AccessControlContext.java:342) 在 java.security.AccessController.checkPermission(AccessController.java:553) 在 java.lang.SecurityManager.checkPermission(SecurityManager.java:549) 在 java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1302) 在 java.lang.System.getProperty(System.java:669) 在 com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:78) 在 com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:893) ... 42 更多
I'm not that new to Java. I've done plenty of stuff with it before. But I'm migrating from PHP to Java Servlet/JSP (which I am new to) and I can't figure out this error to save my life. I installed Tomcat6 using Ubuntu 9.04's Synaptic Package Manager and it works like a charm. But when I put struts in my WEB-INF/lib directory and try to make a struts app, I get the below in the log file.
I used the struts-blank.war to start the project, so the web.xml is the same as provided in struts 2.1.8.1.
It appears that there is some issue with reading the struts-default.xml file.
Thanks in advance
SEVERE: Exception starting filter struts2
Unable to load configuration. - Class: java.security.AccessControlContext
File: AccessControlContext.java
Method: checkPermission
Line: 342 - java/security/AccessControlContext.java:342:-1
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:431)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4359)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.access$000(ContainerBase.java:123)
at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:145)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:769)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:177)
Caused by: Unable to load configuration. - Class: java.security.AccessControlContext
File: AccessControlContext.java
Method: checkPermission
Line: 342 - java/security/AccessControlContext.java:342:-1
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418)
... 36 more
Caused by: Caught exception while loading file struts-default.xml - Class: java.security.AccessControlContext
File: AccessControlContext.java
Method: checkPermission
Line: 342 - java/security/AccessControlContext.java:342:-1
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:902)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:143)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:110)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:168)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
... 38 more
Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission xwork.saxParserFactory read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:342)
at java.security.AccessController.checkPermission(AccessController.java:553)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1302)
at java.lang.System.getProperty(System.java:669)
at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:78)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:893)
... 42 more
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我进行了一次头脑风暴,并自己解决了这个问题。虽然我不认为这是最安全的解决方案,但它适合我的目的,而且我并不担心,因为它是一个本地开发服务器,仅侦听环回接口(127.0.0.1)。
无论如何,解决方案是将其添加到 /etc/tomcat6/policy.d/50local.policy 的底部
I had a brain storm and figured this out myself. Although I don't think this is the most secure solution, but it works for my purposes and I'm not that concerned because it's a local dev server that only listens on the loopback interface (127.0.0.1).
Anyway, the solution is to add this to the bottom of /etc/tomcat6/policy.d/50local.policy