Struts 2 Eclipse Class Not Found错误

时间:2014-08-03 23:17:08

标签: java eclipse struts2 xml-configuration

使用Eclipse配置Struts 2。我很难让它正常工作。据我所知,它可以找到该文件,但它无法加载配置文件。我究竟做错了什么?我已经清理了程序,所有maven依赖项似乎都在那里。我有另一个工作项目,说实话,一切看起来都是相同的,除了一个有效,而这一个没有。

SEVERE: Dispatcher initialization failed
Unable to load configuration. - action - file:/C:/devl/workspaces/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/sunday/WEB-INF/classes/struts.xml:7:70
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)
    at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:193)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4828)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5508)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: Action class [com.manifestcorp.sunday.SundayAction] not found - action - file:/C:/devl/workspaces/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/sunday/WEB-INF/classes/struts.xml:7:70
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:482)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:426)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:552)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:292)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:258)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
    ... 15 more

1 个答案:

答案 0 :(得分:0)

你不应该在新项目中使用FilterDispatcher,这个很久以前就已被弃用了。当前的struts2过滤器类可以在web.xml中配置为

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    <init-param>
        <param-name>actionPackages</param-name>
        <param-value>com.manifestcorp.sunday</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

注意,init参数允许您指定要扫描操作类的包。