Jakarta ee 严重:启动筛选器struts2时出现异常,无法加载配置。-bean-jar:file:struts2-core-2.2.3.jar/struts default.xml:29:72 struts.xml

Jakarta ee 严重:启动筛选器struts2时出现异常,无法加载配置。-bean-jar:file:struts2-core-2.2.3.jar/struts default.xml:29:72 struts.xml,jakarta-ee,struts2,Jakarta Ee,Struts2,struts.xml文件我已经写了这个 <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name=&quo

struts.xml文件我已经写了这个

    <!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.devMode" value="true" />
    
        <package name="default" extends="struts-default" namespace="/">
    
        </package>
    </struts>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
        <filter>
            <filter-name>struts2</filter-name>
            <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>struts2</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
        <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
    </web-app>

堆栈跟踪中提到了您的问题:

Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has
 already been loaded by bean - jar:file:/F:/m/.metadata/.me_tcat/webapps/project/WEB-INF
/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:29:72 - bean - jar:file:/F:/m/.metadata
/.me_tcat/webapps/project/WEB-INF/lib/struts2-core-2.2.3.jar!/struts-default.xml:29:72

似乎在
WEB-INF/lib
目录中有多个
struts2 core-*.jar
。我想你应该只有一个。清理一下。还要查看您的
.classpath
是否没有重复的条目。

错误是直接的:

类com.opensymphony.xwork2.ObjectFactory,名称为xwork 已由bean加载

您是否已将struts2-core-X.X.X.X.jar添加到服务器类路径中?以及项目构建路径


如果是,则移除。它会起作用。

这是一个jar问题。您需要下载所有最新的struts JAR

尝试以下jar库:

  • common-chain-12.jar
  • common-fileupload-1.3.1.jar
  • commons-io-2.2.jar
  • commons-logging-api-1.1.jar
所有常用jar(freemarker.jar、javaassist.jar、ognl.jar、xwork-core.jar、struts2-core.jar)都应该有最新版本


尤其要确保xwork和struts2 core JAR的版本相同。Java 8之后,这些jar不再是可选的。

完全正确,重复的jar导致了同样的问题!,谢谢
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has
 already been loaded by bean - jar:file:/F:/m/.metadata/.me_tcat/webapps/project/WEB-INF
/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:29:72 - bean - jar:file:/F:/m/.metadata
/.me_tcat/webapps/project/WEB-INF/lib/struts2-core-2.2.3.jar!/struts-default.xml:29:72