Search code examples
javainheritancestruts2struts-configxml-configuration

Do we need to extend struts-default package always?


Do we always need to extend the struts-default package? I am seeing following exception on server startup:

Caused by: Error building results for action loginScreen in namespace /User - action - file:/C:/glassfish4/glassfish/domains/domain1/eclipseApps/Struts2Example/WEB-INF/classes/login.xml:9:30

package:

<package name="login" namespace="/User" >
    <action name="loginScreen">
        <result>pages/login.jsp</result>
    </action>
</package>

if I add the extends="struts-default" to above package then server is starts up without any error.

Can someone please give more details on this error/exception?


Solution

  • In your configuration you are using a dispatcher result type by default to configure your result. But this type is defined in the struts-default package which your package should extend. It's not obligatory to extend this package, but to have support from the Struts2 framework you need at least your root package extend the struts-default.