我只是想设置一个Struts2环境。
我有一个tomcat7工作正常。我按照struts2教程,下载了struts,将struts库复制到/usr/share/tomcat7/lib
。我从网络界面尝试部署struts2-blank.war
演示。
战争上传很好,出现在tomcat管理器的应用程序列表中,但是当我单击 start 时,我在Web界面中收到以下错误:
FAIL - Application at context path /struts2-blank could not be started
查看日志以获取更多详细信息,我每次尝试start
struts2-blank
应用时都会发现这一点:
Oct 19, 2016 6:53:55 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: /struts-tags is already defined
Oct 19, 2016 6:53:55 PM org.apache.catalina.startup.TldConfig execute
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Oct 19, 2016 6:53:56 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: One or more Filters failed to start. Full details will be found in the appropriate container log file
Oct 19, 2016 6:53:56 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/struts2-blank] startup failed due to previous errors
在其他日志文件中:
Oct 19, 2016 7:04:31 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: start: Starting web application '/struts2-blank'
Oct 19, 2016 7:04:33 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
Unable to load configuration. - bean - jar:file:/var/lib/tomcat7/webapps/struts2-blank/WEB-INF/lib/struts2-core-2.3.28.jar!/struts-default.xml:63:72
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:496)
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.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4909)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5602)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1312)
at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:690)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:216)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:136)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:221)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: Unable to load configuration. - bean - jar:file:/var/lib/tomcat7/webapps/struts2-blank/WEB-INF/lib/struts2-core-2.3.28.jar!/struts-default.xml:63:72
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:970)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:438)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:482)
... 39 more
Caused by: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - jar:file:/var/lib/tomcat7/webapps/struts2-blank/WEB-INF/lib/struts2-core-2.3.28.jar!/struts-default.xml:63:72
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:247)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:240)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 42 more
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name struts has already been loaded by bean - jar:file:/usr/share/tomcat7/lib/struts2-core-2.3.28.jar!/struts-default.xml:63:72 - bean - jar:file:/var/lib/tomcat7/webapps/struts2-blank/WEB-INF/lib/struts2-core-2.3.28.jar!/struts-default.xml:63:72
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:231)
... 45 more
Oct 19, 2016 7:04:33 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
相关的行似乎是找不到jar文件,至少对于核心:
Unable to load configuration. - bean - jar:file:/var/lib/tomcat7/webapps/struts2-blank/WEB-INF/lib/struts2-core-2.3.28.jar!/struts-default.xml:63:72
确实如此,但即使手动将jar文件复制到该目录后,我也遇到了同样的错误。
有人能指出我正确的方向吗?
答案 0 :(得分:2)
这是错误的
将struts库复制到/ usr / share / tomcat7 / lib
在 库已经与演示应用程序一起打包。部署应用程序后,您将拥有由类加载器加载的重复jar文件。从Tomcat共享lib中删除Struts jar并重新部署您的演示应用程序。
此外,如果您使用Tomcat管理器应用程序来部署您的应用程序,那么如果部署成功,它应该已经启动。您无需手动启动/停止它。
检查服务器日志文件以查看部署期间的错误。
最后,如果您仍然决定将war文件手动复制到Tomcat部署目录webapps
,请确保已取消部署旧版本。