Struts2 in RAD raises error - xwork has already been loaded by bean

自闭症网瘾萝莉.ら 提交于 2019-12-11 06:14:47

问题


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:


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


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.

I have a Web project called "Struts2Demo" project. And a separate project called "JARS" which contains all the required jars.

All the required jars for Struts2Demo web project are configured using "J2EE Module Dependencies - Web Libraries" referencing "JARS" project.

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.

So, my question is there any way to fix this configuration other than putting required jars in WEB-INF/lib


回答1:


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.



来源:https://stackoverflow.com/questions/2778140/struts2-in-rad-raises-error-xwork-has-already-been-loaded-by-bean

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!