RAD 中的 Struts2 引发错误 - xwork 已被 bean 加载 [英] Struts2 in RAD raises error - xwork has already been loaded by bean
问题描述
我使用 RAD 7.0 来开发 Struts2 应用程序.当我在 websphere 6.1 上的 RAD 中运行 web 应用程序时,出现以下错误:
I am using RAD 7.0 for developing Struts2 app. When I run the web app inside RAD on websphere 6.1, I get following error:
无法初始化]:无法加载 bean:类型:类:com.opensymphony.xwork2.ObjectFactory - bean -wsjar:file:/C:/workspace_test/Jars/struts2-core-2.0.11.2.jar!/struts-default.xml:30:72在com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:208).... 更多 原因:Bean 类型类com.opensymphony.xwork2.ObjectFactory 与名称 xwork 已经已被 bean 加载 -wsjar:file:/C:/workspace_test/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/Struts2Demo/WEB-INF/lib/struts2-core-2.0.11.2.jar!/struts-default.xml:30:72- bean - wsjar:file:/C:/workspace_test/Jars/struts2-core-2.0.11.2.jar!/struts-default.xml:30:72在com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:193)... 33 更多
could not be initialized]: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - wsjar:file:/C:/workspace_test/Jars/struts2-core-2.0.11.2.jar!/struts-default.xml:30:72 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:208) .... more Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has already been loaded by bean - wsjar:file:/C:/workspace_test/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/Struts2Demo/WEB-INF/lib/struts2-core-2.0.11.2.jar!/struts-default.xml:30:72 - bean - wsjar:file:/C:/workspace_test/Jars/struts2-core-2.0.11.2.jar!/struts-default.xml:30:72 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:193) ... 33 more
<小时>
我知道这是由于 2 个 struts2 jar 副本造成的.让我解释一下我是如何在 RAD 环境中配置我的 Web 项目的.
I understand that this is due to 2 copies of struts2 jars. Let me explain how I have configured my web project in the RAD environment.
我有一个名为Struts2Demo"的 Web 项目.还有一个名为JARS"的单独项目,其中包含所有必需的 jar.
I have a Web project called "Struts2Demo" project. And a separate project called "JARS" which contains all the required jars.
Struts2Demo Web 项目所需的所有 jar 均使用J2EE 模块依赖项 - Web 库"引用JARS"项目进行配置.
All the required jars for Struts2Demo web project are configured using "J2EE Module Dependencies - Web Libraries" referencing "JARS" project.
因此,在加载 Web 应用程序时,RAD 正在加载来自JARS"项目和 eclipse 临时文件夹/C:/workspace_test/.metadata/.plugins/org.eclipse.wst.server.core/"的 jarstmp0/Struts2Demo/WEB-INF/lib/",因此出现错误.
So the RAD while loading the web app is loading the jars from "JARS" project and also from the eclipse temp folder "/C:/workspace_test/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/Struts2Demo/WEB-INF/lib/", hence the error.
所以,我的问题是除了将所需的 jars 放在 WEB-INF/lib 中之外,还有什么方法可以修复此配置
So, my question is there any way to fix this configuration other than putting required jars in WEB-INF/lib
推荐答案
零体验 RAD.但是标准的做法是将 struts jars(通常是大多数 jars)放在每个 web 应用程序的 WEB-INF/lib 中.重复带来的不便通常被 Web 应用程序之间的每个库(不同的类加载器)中的类隔离所抵消,这有助于避免您遇到的问题.
Zero experience with RAD. But the standard practice, is to put the struts jars (and, in general, most of the jars) in the WEB-INF/lib of each web-application. The duplication inconvenience is usually outweighed by the isolation of classes from each library (different classloaders) among webapps, which helps to avoid problems as yours.
这篇关于RAD 中的 Struts2 引发错误 - xwork 已被 bean 加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!