AWG Blogs

Sunday, November 2, 2014

Solving Sruts2 Core Jar File Conflict

I was adding a Struts2 application to an embedded Tomcat 6 instance by adding the context and assigning the path to the Struts2 application programmatically. The Struts2 application's WEB-INF/lib was empty similar to what's known as a "skinny war." When attempting to access a jsp page though I would get the error: "/struts-tags" not found.

This was solved by adding struts2-core-2.3.4.1.jar to the WEB-INF/lib. However then application would not load and I would get:
Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has already been loaded by bean - jar:file:C:/MyCustomContainer/plugins/struts2-core-2.3.4.1.jar!/struts-default.xml:29:72 - bean - jar:file:/D:/temp/configs/pings/strutssd/WEB-INF/lib/struts2-core-2.3.4.1.jar!/struts-default.xml:29:72

So I removed struts2-core-2.3.4.1.jar from the plugins dir leaving only the copy in the WEB-INF/lib. This fixed the problem and the Struts2 application finally worked.

Note this could cause problems if I were to add another Struts2 application to the container although I haven't tried it.

Related problems with workarounds including removing struts-tags.tld and putting in WEB-INF, or adding Class-Path entries  to MANIFEST.MF:
http://stackoverflow.com/questions/19380836/skinny-war-libraries-in-ear-struts-tags-not-found-error
http://stackoverflow.com/questions/6339323/file-struts-tags-not-found-in-struts-1-3
http://stackoverflow.com/questions/19666413/what-is-the-right-way-to-package-struts2-jar-files
http://docs.codehaus.org/display/MAVENUSER/Solving+the+Skinny+Wars+problem

No comments:

Post a Comment