我正在学习Struts2.By使用谷歌我开发了一个基本的应用程序。我在使用eclipse开发时,我试图运行我的应用程序它给了我错误
严重:异常启动过滤器struts2
然后我导出为war文件然后我手动复制到tomcat(Apache tomcat 6.0.35)webapps文件夹然后我试图运行它现在工作正常。所以我检查日食中的日志文件
Aug 19, 2014 9:19:12 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SpinnerTest' did not find a matching property.
Aug 19, 2014 9:19:12 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:StrutsDemo' did not find a matching property.
Aug 19, 2014 9:19:12 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Aug 19, 2014 9:19:12 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 625 ms
Aug 19, 2014 9:19:12 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Aug 19, 2014 9:19:12 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
Aug 19, 2014 9:19:12 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
java.lang.ExceptionInInitializerError
at org.apache.struts2.dispatcher.ng.InitOperations.createDispatcher(InitOperations.java:110)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:73)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
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:601)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "xwork.loggerFactory" "read")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
at java.security.AccessController.checkPermission(AccessController.java:560)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1302)
at java.lang.System.getProperty(System.java:706)
at com.opensymphony.xwork2.util.logging.LoggerFactory.getLoggerFactory(LoggerFactory.java:64)
at com.opensymphony.xwork2.util.logging.LoggerFactory.getLogger(LoggerFactory.java:45)
at org.apache.struts2.dispatcher.Dispatcher.<clinit>(Dispatcher.java:103)
... 21 more
Aug 19, 2014 9:19:12 PM org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
Aug 19, 2014 9:19:12 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/StrutsDemo] startup failed due to previous errors
通过跟随this link我添加了以下行
permission java.util.PropertyPermission "xwork.loggerFactory", "read";
现在我收到以下错误
SEVERE: Dispatcher initialization failed
com.opensymphony.xwork2.inject.DependencyException: Security manager in use, could not access constructor: org.apache.struts2.util.fs.JBossFileManager(org.apache.struts2.util.fs.JBossFileManager)
at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.<init>(ContainerImpl.java:334)
at com.opensymphony.xwork2.inject.ContainerImpl$5.create(ContainerImpl.java:311)
at com.opensymphony.xwork2.inject.ContainerImpl$5.create(ContainerImpl.java:307)
at com.opensymphony.xwork2.inject.util.ReferenceCache$CallableCreate.call(ReferenceCache.java:150)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at com.opensymphony.xwork2.inject.util.ReferenceCache.internalCreate(ReferenceCache.java:76)
at com.opensymphony.xwork2.inject.util.ReferenceCache.get(ReferenceCache.java:116)
at com.opensymphony.xwork2.inject.ContainerImpl.getConstructor(ContainerImpl.java:607)
at com.opensymphony.xwork2.inject.ContainerBuilder$5.create(ContainerBuilder.java:204)
at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51)
at com.opensymphony.xwork2.inject.ContainerBuilder$3.create(ContainerBuilder.java:93)
at com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:487)
at com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:484)
at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:584)
at com.opensymphony.xwork2.inject.ContainerBuilder.create(ContainerBuilder.java:484)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.createBootstrapContainer(DefaultConfiguration.java:340)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:229)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
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:601)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.security.AccessControlException: access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
at java.security.AccessController.checkPermission(AccessController.java:560)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.<init>(ContainerImpl.java:330)
... 40 more
Aug 20, 2014 7:50:01 AM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
Security manager in use, could not access constructor: org.apache.struts2.util.fs.JBossFileManager(org.apache.struts2.util.fs.JBossFileManager) - Class: com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector
File: ContainerImpl.java
Method: <init>
Line: 334 - com/opensymphony/xwork2/inject/ContainerImpl.java:334:-1
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:501)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
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:601)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: com.opensymphony.xwork2.inject.DependencyException: Security manager in use, could not access constructor: org.apache.struts2.util.fs.JBossFileManager(org.apache.struts2.util.fs.JBossFileManager)
at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.<init>(ContainerImpl.java:334)
at com.opensymphony.xwork2.inject.ContainerImpl$5.create(ContainerImpl.java:311)
at com.opensymphony.xwork2.inject.ContainerImpl$5.create(ContainerImpl.java:307)
at com.opensymphony.xwork2.inject.util.ReferenceCache$CallableCreate.call(ReferenceCache.java:150)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at com.opensymphony.xwork2.inject.util.ReferenceCache.internalCreate(ReferenceCache.java:76)
at com.opensymphony.xwork2.inject.util.ReferenceCache.get(ReferenceCache.java:116)
at com.opensymphony.xwork2.inject.ContainerImpl.getConstructor(ContainerImpl.java:607)
at com.opensymphony.xwork2.inject.ContainerBuilder$5.create(ContainerBuilder.java:204)
at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51)
at com.opensymphony.xwork2.inject.ContainerBuilder$3.create(ContainerBuilder.java:93)
at com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:487)
at com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:484)
at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:584)
at com.opensymphony.xwork2.inject.ContainerBuilder.create(ContainerBuilder.java:484)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.createBootstrapContainer(DefaultConfiguration.java:340)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:229)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)
... 20 more
Caused by: java.security.AccessControlException: access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
at java.security.AccessController.checkPermission(AccessController.java:560)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.<init>(ContainerImpl.java:330)
... 40 more
Aug 20, 2014 7:50:01 AM org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
Aug 20, 2014 7:50:01 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/StrutsDemo] startup failed due to previous errors
即使是简单的staruts-blank.war也没有在eclipse中工作,它给出了同样的错误,但是当手动部署到tomcat时它也工作正常。我正在使用java7.So可以任何一个请指导我如何解决这个问题?
感谢先生
答案 0 :(得分:0)
您的tomcat似乎已激活SecurityManager,并且struts2需要多个权限才能工作。
您可以禁用SecurityManager(它是VM arg)或配置catalina.policy文件以向WebApp授予权限。即。
grant codeBase "file:${catalina.base}/webapps/<your-webapp>/-" {
permission java.security.AllPermission;
};
答案 1 :(得分:0)
首先检查web.xml
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
检查所有Jar并且好好不要在lib文件夹中重复jar。 你得到所有jar文件的列表,以便轻松使用run struts项目。