0

我是 maven 新手,我正在尝试使用 struts2、Hibernate 和 spring3 构建应用程序。

当我尝试在 tomcat 服务器上部署我的应用程序时,出现以下错误。

SEVERE: Exception starting filter struts2
Unable to load configuration. - action - file:/C:/Prashant/WorkSpace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/EmployeeManagementSystem/WEB-INF/classes/struts.xml:17:64
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:360)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:403)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:48)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:273)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:254)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:372)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4461)
    at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5133)
    at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5128)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Caused by: Action class [dispEmployeeAction] not found - action - file:/C:/Prashant/WorkSpace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/EmployeeManagementSystem/WEB-INF/classes/struts.xml:17:64
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:405)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:355)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:460)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:265)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:189)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
    ... 16 more
14 Apr, 2013 1:58:28 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
14 Apr, 2013 1:58:28 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/EmployeeManagementSystem] startup failed due to previous errors
14 Apr, 2013 1:58:28 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext

此错误消息说未找到操作类 [dispEmployeeAction] - 操作 - 文件:/C:/Prashant/WorkSpace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/EmployeeManagementSystem/WEB-INF /classes/struts.xml:17:64 但在我的 struts.xml 中,我将此操作映射为如下。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>

    <constant name="struts.enable.DynamicMethodInvocation" value="flase"></constant>
    <constant name="struts.devMode" value="true"></constant>

    <package name="default" extends="struts-default">

        <interceptors>
            <interceptor name="myInterceptor" class="action.MyInterceptor"></interceptor>
        </interceptors>

        <!-- For Employee Action mapping -->
        <action name="dispEmployeeAction" class="dispEmployeeAction">
            <result name="success">/employee_add.jsp</result>
        </action>

        <action name="employeeAction" class="employeeAction">
            <result name="input">/employee_add.jsp</result>
            <result name="list">/employee_list.jsp</result>
        </action>

        <action name="dispEmployeeListAction" class="dispEmployeeListAction">
            <result name="success">/employee_list.jsp</result>
        </action>

        <action name="employeeListAction" class="employeeListAction">
            <result name="success">/employee_list.jsp</result>
            <result name="new">/employee_add.jsp</result>
        </action>

    </package>
</struts>

并且 pom.xml 如下

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>EmployeeManagementSystem</groupId>
    <artifactId>EmployeeManagementSystem</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>EmployeeManagementSystem</name>
    <description>EmployeeManagementSystem</description>
    <dependencies>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.5.4-Final</version>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-core</artifactId>
            <version>2.1.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-dojo-plugin</artifactId>
            <version>2.3.8</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>3.2.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.2.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.2.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>3.2.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>3.2.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>3.2.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>3.2.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.2.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-hibernate3</artifactId>
            <version>2.0.7</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>           
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.24</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-jdk14</artifactId>
            <version>1.5.8</version>
        </dependency>
        <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.12.1.GA</version>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-tiles-plugin</artifactId>
            <version>2.3.8</version>
        </dependency>
    </dependencies>
</project>
4

1 回答 1

0

您已将 Struts 2 jar 放在 Tomcat 库目录中:

原因:名称为 xwork 的 bean 类型类 com.opensymphony.xwork2.ObjectFactory 已被 bean - jar:file:/C:/apache-tomcat-7.0.25-windows-x86/apache-tomcat-7.0 加载。 25/lib/struts2-core-2.3.4.1.jar!/struts-default.xml:29:72

从 servlet 容器中移除 Struts 相关的库;仅使用您的应用程序部署它们。

于 2013-10-21T06:29:08.317 回答