I'm upgrading some old legacy applications to Maven. These applications run in WebSphere Application Server traditional 8.5.5 and I'm using Eclipse 4.16.0 to run the WAS server.
It compiles just fine, however, when I try to access web applications that are built with Struts, I have the following error message in the browser:
Error 500: javax.servlet.ServletException: Filter [struts2]: could not be initialized
And, in the server logs, I have this:
[30/05/23 10:37:26:986 BRT] 000000b6 webapp E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor]: Unable to load configuration. - bean - wsjar:file:/C:/Users/DouglasCanevarollo/Desktop/ibm/evs/evs-maven/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/evs-ip-upload/WEB-INF/lib/struts2-core-6.1.2.jar!/struts-default.xml:116:72
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:566)
at org.apache.struts2.dispatcher.InitOperations.initDispatcher(InitOperations.java:48)
at org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:60)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.init(FilterInstanceWrapper.java:145)
...
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name struts has already been loaded by bean - wsjar:file:/C:/Users/DouglasCanevarollo/.m2/repository/org/apache/struts/struts2-core/6.1.2/struts2-core-6.1.2.jar!/struts-default.xml:116:72 - bean - wsjar:file:/C:/Users/DouglasCanevarollo/Desktop/ibm/evs/evs-maven/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/evs-ip-upload/WEB-INF/lib/struts2-core-6.1.2.jar!/struts-default.xml:116:72
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:263)
... 34 more
How can I solve this conflict?
These are my Struts configuration files:
struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 6.0.//EN"
"http://struts.apache.org/dtds/struts-6.0.dtd">
<struts>
...
<!-- Package -->
<package name="default" namespace="/protect" extends="struts-default">
<!-- Action Mappings -->
<action name="uploadIpDb" method="runInit" class="com.ibm.comexp.ipupload.action.IPUploadAction" >
<result>/home.jsp</result>
</action>
...
</package>
</struts>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
...
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name struts has already been loaded by
Don't use the same library twice on the classpath struts2-core-6.1.2.jar
. The struts configuration contains in this library in the struts-default.xml
. It should be loaded only once when struts2 filter is initialized. Remove the duplicate library from the classpath after deploy of your application.