Juicy Juicy - 1 month ago 16
Java Question

Can't deploy Struts2 demos

I'm just trying to set up a Struts2 environment.

I have a tomcat7 working fine. I followed a struts2 tutorial, downloaded struts, copied the struts libraries to

/usr/share/tomcat7/lib
. From the web interface I tried deploying the
struts2-blank.war
demo.

The war uploads fine, appears in my list of Applications in the tomcat manager, but when I click start I get the following error in the web interface:

FAIL - Application at context path /struts2-blank could not be started


Looking in the logs for more details, I find this everytime I try to
start
the
struts2-blank
app:

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


In the other log file:

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'


The relevant line seems to be that it can't find the jar files, at least for core:

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


That is indeed true, but even after manually copying the jar file to that directory, I got the same error.

Can someone point me in the right direction?

Answer

This is wrong

copied the struts libraries to /usr/share/tomcat7/lib

The libraries are already packaged with the demo application. After deploying the application you have duplicated jar files loaded by the classloaders. Remove Struts jars from Tomcat share lib and redeploy your demo application.

Also if you are using Tomcat manager app to deploy your application, it should be already started if deployment was successful. You don't need to start/stop it manually.

Check the server log file to see errors during deployment.

Lastly, if you still decided to manually copy war file to the Tomcat deployment dir webapps, make sure you have undeployed the old version.