java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter in web.xml

前端 未结 8 1059
花落未央
花落未央 2020-12-06 07:16

This is my web.xml Code,While running I am getting error like this..How to resolve this?

\"SEVERE: Exception starting filter Struts java.lang.ClassNotFoundEx

相关标签:
8条回答
  • 2020-12-06 07:30

    Starting with Struts 2.5 the StrutsPrepareAndExecuteFilter has been moved to the org.apache.struts2.dispatcher.filter package (without the "ng" in the package).

    0 讨论(0)
  • 2020-12-06 07:39

    This will occur because the correct version of the struts2-core.jar is not on the lib path. Please check your lib directory and ensure that you have the right version of struts2-core.jar.

    If you have the jar in your lib folder, then you will need to ensure that you are including the correct project library when you deploy your code to your application container. If the Struts 2 Project Library files are not included when you deploy, this error will also occur.

    0 讨论(0)
  • 2020-12-06 07:44

    Another solution, if the rest of answers doesn't work for you

    If you put the right package path (without .ng..) and you still get:

    java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
    

    I had the same problem but none of this solutions works, because I got the same error using the right path but the reason was how the class loader load the classes.

    The solution is to set in the WAS "Classes loaded with local class loader first (parent last)"

    To do this:

    • Click on WebSphere enterprise applications.
    • Choose your enterprise application
    • Click on Manage Modules.
    • Click on your module.
    • "Select Classes loaded with local class loader first (parent last)" from the Class loader order drop down list.
    • Click on OK.
    • Click on Save.
    • restart the websphere server (or virtual server in my case).

    If this work for you then the best way of doing this is setting an deployment.xml in the EAR project, so in futures deployment this is setted automated:

    <?xml version="1.0" encoding="UTF-8"?> 
    <appdeployment:Deployment 
            xmi:version="2.0" 
            xmlns:xmi="http://www.omg.org/XMI" 
            xmlns:appdeployment=" 
    http://www.ibm.com/websphere/appserver/schemas/5.0/appdeployment.xmi"> 
    
            <deployedObject xmi:type="appdeployment:ApplicationDeployment" 
    startingWeight="10"> 
    
                    <modules 
                            xmi:type="appdeployment:WebModuleDeployment" 
                            startingWeight="10000" 
                            uri="<your war name>" 
                            classloaderMode="PARENT_LAST" /> 
                    <classloader mode="PARENT_LAST" /> 
            </deployedObject> 
    </appdeployment:Deployment>
    

    I found out the solution here: Solution - class loader configuration in WAS

    0 讨论(0)
  • 2020-12-06 07:46

    Make sure your struts2 library include in you deploy project. Add your struts2 library under WEB-INF file. Then add that to your build path.

    0 讨论(0)
  • 2020-12-06 07:49

    in my case, i was using 2.3.3 with "org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter" following the original struts guide in the oficial page, i just changed my version to 2.5 and it worked

    0 讨论(0)
  • 2020-12-06 07:53

    if you are using struts2 version 2.5 you need to change from:

    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
    

    to:

    org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
    

    Version Notes 2.5

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