Search code examples
javastruts2strutsstruts-1struts-config

Struts2: ConfigurationManager and/or Configuration should not be null


I'm mid way into struts1 to struts2 migration and got the following error. I havent any solution where to start and how to fix it. It builds successfully and after starting the webapp with tomcat,this error comes up and the deployment fails:

SCHWERWIEGEND [http-nio-8184-exec-6] org.apache.catalina.core.StandardContext.filterStart Ausnahme beim Starten des Filters [struts2]
    ConfigurationManager and/or Configuration should not be null - Class: org.apache.struts2.dispatcher.Dispatcher
File: Dispatcher.java
Method: getContainer
Line: 1162 - org/apache/struts2/dispatcher/Dispatcher.java:1162:-1

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
         version="2.4">

    <display-name>xxx</display-name>
    
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
        <init-param>
            <param-name>config</param-name>
            <param-value>WEB-INF/struts.xml</param-value>
        </init-param>
        <init-param>
            <param-name>log4j-init-file</param-name>
            <param-value>WEB-INF/classes/log4j2.xml</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
  

    <servlet>
        <servlet-name>InitActionServlet</servlet-name>
        <servlet-class>Utilities.InitActionServlet</servlet-class>
        <init-param>
            <param-name>mailhost</param-name>
            <param-value>localhost</param-value>
        </init-param>
        <init-param>
            <param-name>mailhost-port</param-name>
            <param-value>2525</param-value>
        </init-param>
        <init-param>
        <init-param>
            <param-name>CommonSecret</param-name>
            <param-value>xxx</param-value>
        </init-param>     
        <init-param>
            <param-name>
                xxx
            </param-name>
            <param-value>
                http://localhost:8084/xxx
            </param-value>
        </init-param>
        <load-on-startup>0</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>InitActionServlet</servlet-name>
        <url-pattern>/initAction</url-pattern>
    </servlet-mapping>
         
    <welcome-file-list>
        <welcome-file>
            index.jsp
        </welcome-file>
    </welcome-file-list>
    
    <security-constraint>
        <display-name>xxx</display-name>
        <web-resource-collection>
            <web-resource-name>xxx</web-resource-name>
            <description>protected resources</description>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>xxx</role-name>
            <role-name>xxx</role-name>
        </auth-constraint>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>

    <login-config>
        <auth-method>BASIC</auth-method>
    </login-config>

    <security-role>
        <description>xxx</description>
        <role-name>xxx</role-name>
    </security-role>
    <security-role>
        <description>xxx</description>
        <role-name>xxx</role-name>
    </security-role>

    <distributable/>
</web-app>

Thanks in advance!

Solution how to fix this error and explanation.


Solution

  • config is not a valid init parameter for org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter. If you need to learn more how to use this parameter read this answer.

    The configuration file struts.xml should be on classpath. You should read more about suruts.xml:

    The core configuration file for the framework is the default (struts.xml) file and should reside on the classpath of the webapp (generally /WEB-INF/classes).