Struts2 Error when Deploying: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory

前端 未结 5 629
暗喜
暗喜 2021-01-18 09:00

I\'m creating a basic Struts2, Maven webApp and getting this error when I deploy to Tomcat 6 or Jetty. Has anyone seen this?

  2010-07-29 15:33:38.801::WARN         


        
相关标签:
5条回答
  • 2021-01-18 09:29

    Agree with the above answer

    Check your library and classpath for the above jars and fix them

    Sometimes even if the jars are not seen in the IDE, they are present int the build files, So a fix of the classpath and a CLEAN AND BUILD should resolve the problem.

    0 讨论(0)
  • 2021-01-18 09:33

    I have also encountered this problem recently. Clean the cache and rebuild the project is not valid for my error. I tried to delete the conflicting struts-default.xml file, but I didn't find it and the struts-default.xml file is a read-only file so I can't to modify it. My final solution is to remove the extra Web* under Project Structure--Modules--MyFirstProject (project name), leaving only one Web and modifying Web Resource Directories as WebRoot. It works for me! Hope I can help others. ​​​​​​​​​​here

    0 讨论(0)
  • 2021-01-18 09:40

    Your problem is actually quite clear if you read the stack trace:

    Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the 
    name xwork has already been loaded by bean -
    jar:file:/C:/workspaces/ulearn/ulearn/target/work/webapp/WEB-INF/lib/struts2-core-2.0.11.2.jar!/struts-default.xml:30:72
     - bean -
    jar:file:/C:/workspaces/ulearn/ulearn/target/work/webapp/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:29:72
    

    You have a copy of struts2-core-2.0.11.2.jar and a copy of struts2-core-2.1.8.1.jar in your WEB-INF/lib directories. I think you should only have one of them. Do some cleanup (running a mvn clean might be enough).


    PS: I have no idea why you also have stuff coming from C:/workspace/test as show be the first line:

    jar:file:/C:/workspaces/test/test/target/work/webapp/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:29:72
    

    There is definitely something weird and messy with your classpath. I don't have any explanation beyond the one I gave above though.

    0 讨论(0)
  • 2021-01-18 09:42

    I think struts2-core-2.1.8.1.jar copy or you have included this jar file some where in your webapplication so remove it and continue

    0 讨论(0)
  • 2021-01-18 09:45

    Problem: The conflict occurred as 2 files of different versions are being loaded by the web container

    Solution: Just go to path C:/workspaces/ulearn/ulearn/target/work/webapp/WEB-INF/lib/ of your computer and delete the struts2-core-2.0.11.2.jar file and only keep the latest one. If this type of conflict also occurs with some other file then delete that file also After this no exception will be there.

    0 讨论(0)
提交回复
热议问题