Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
184 views
in Technique[技术] by (71.8m points)

configuration - Struts2 Unable to instantiate Action, com.xxx.action.domain.MyAction, defined for '' in namespace '/admin/myresource 'Class must not be null

New to Struts2. I am running this project for the first time and I am getting this error message when browsing to all the resources. It looks like struts.xml is not seen at all.

I have the feeling that it must be something to do with some misconfiguration and/or a missing jar. That "defined for ''" (with that empty space between quotes) is the bit that worries me the most.

The project is a web app and is built with maven. Any idea, advice or just thoughts are welcome.

My struts.xml includes my struts-xxx.xml like this

<include file="struts-xxx.xml"/>

In struts-xxx.xml:

<package name="xxx-admin" namespace="/admin/myresource" extends="my-default">

    <default-action-ref name="default"/>
    <default-class-ref class="com.xxx.action.domain.MyAction"/>

    <global-results>
        <result type="redirectAction">list</result>
        <result name="detail">/WEB-INF/jsp/xxx/detail.jsp</result>
        <result name="input">/WEB-INF/jsp/xxx/detail.jsp</result>
    </global-results>

    <action name="default">
        <result type="redirectAction">
            <param name="actionName">list</param>
        </result>
    </action>

    <action name="view" method="view"/>
    <action name="create" method="create"/>
    <action name="update" method="update"/>
    <action name="delete" method="delete"/>

    <action name="commit_create" method="createCommit">
        <result name="detail" type="redirectAction">create</result>
        <!--stay creating-->
    </action>
    <action name="commit_update" method="updateCommit">
        <result name="detail" type="redirectAction">
            <!--stay updating-->
            <param name="parse">true</param>
            <param name="actionName">update</param>
            <param name="id">%{id}</param>
        </result>
    </action>
    <action name="commit_delete" method="deleteCommit"/>


    <action name="search" method="search" class="com.xxx.action.domain.OneMoreAction">
        <result>/WEB-INF/jsp/xxx/search.jsp</result>
    </action>

    <action name="list" method="list" class="com.xxx.action.domain.OneMoreAction">
        <result>/WEB-INF/jsp/xxx/list.jsp</result>
        <result name="input">/WEB-INF/jsp/xxx/search.jsp</result>
        <result name="unique_result">/WEB-INF/jsp/xxx/list.jsp</result>
    </action>

</package>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There was nothing wrong with Struts2 config (or Spring config). The project I was trying to run was coded with Java 1.6 while I was using Java 1.7 ... thanks for your answers and comments


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...