Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Struts2 Bean已经加载了名为xwork的Bean类型类com.opensymphony.xwork2.ObjectFactory_Struts2_Embedded Jetty - Fatal编程技术网

Struts2 Bean已经加载了名为xwork的Bean类型类com.opensymphony.xwork2.ObjectFactory

Struts2 Bean已经加载了名为xwork的Bean类型类com.opensymphony.xwork2.ObjectFactory,struts2,embedded-jetty,Struts2,Embedded Jetty,我正在尝试部署一个带有Jetty嵌入式实例的简单webapp。我的嵌入式测试代码是: public static void main(String[] args) throws Exception{ Server server = new Server(8181); WebAppContext webAppContext = new WebAppContext(); webAppContext.setContextPath("/"); webAppContext.

我正在尝试部署一个带有Jetty嵌入式实例的简单webapp。我的嵌入式测试代码是:

public static void main(String[] args) throws Exception{
    Server server = new Server(8181);
    WebAppContext webAppContext = new WebAppContext();
    webAppContext.setContextPath("/");
    webAppContext.setWar(ContUtil.warPath + ContUtil.warName);
    server.setHandler(webAppContext);

    logger.info("starting jetty...");
    server.start();
    server.join();
} 
但我得到了以下错误:

Caused by: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - jar:file:/C:/Users/lingguo/AppData/Local/Temp/jetty-0.0.0.0-8181-MemCloud-Web-1.0-SNAPSHOT.war-_-any-6830790104248388668.dir/webapp/WEB-INF/lib/struts2-core-2.2.1.jar!/struts-default.xml:29:72
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:232)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:180)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
    ... 23 more
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has already been loaded by bean - jar:file:/D:/Program%20Files%20(x86)/apache-maven-2.2.1/repo/org/apache/struts/struts2-core/2.2.1/struts2-core-2.2.1.jar!/struts-default.xml:29:72 - bean - jar:file:/C:/Users/lingguo/AppData/Local/Temp/jetty-0.0.0.0-8181-MemCloud-Web-1.0-SNAPSHOT.war-_-any-6830790104248388668.dir/webapp/WEB-INF/lib/struts2-core-2.2.1.jar!/struts-default.xml:29:72
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:216)
    ... 26 more
关于这个问题,我引用了许多类似的答案,例如:;大多数类似的问题都是由不同版本的jar包冲突引起的。但我的问题有点不同。我确保在我的类路径中只有一个版本的struts2 core(2.2.1)

我检查了错误消息,我认为jetty创建了一个tmp文件,即:
/C:/Users/linguo/AppData/Local/Temp/jetty-0.0.0-8181-MemCloud-Web-1.0-SNAPSHOT.war-u2;-any-68307901004248388668.dir
,jar struts2-core-2.2.1与本地maven存储库中的jar相一致


谁知道哪里出了问题?提前谢谢

您是否尝试从目录中删除了有冲突的jar文件?我认为您打包了错误的应用程序。谢谢您的评论
/D:/Program%20Files%20(x86)/apache-maven-2.2.1/repo
是maven的本地存储库。我不知道如何生成。