• 【转】Struts2 严重: Dispatcher initialization failed java.lang.RuntimeException


    严重: Dispatcher initialization failed
    java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
     at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:295)
     at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:431)
     at com.opensymphony.xwork2.inject.ContainerBuilder$5.create(ContainerBuilder.java:207)
     at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51)
     at com.opensymphony.xwork2.inject.ContainerBuilder$3.create(ContainerBuilder.java:93)
     at com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:487)
     at com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:484)
     at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:574)
     at com.opensymphony.xwork2.inject.ContainerBuilder.create(ContainerBuilder.java:484)
     at com.opensymphony.xwork2.config.impl.DefaultConfiguration.createBootstrapContainer(DefaultConfiguration.java:252)
     at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:193)
     at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
     at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)
     at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
     at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
     at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
     at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
     at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
     at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
     at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3800)
     at org.apache.catalina.core.StandardContext.start(StandardContext.java:4450)
     at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
     at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
     at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
     at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
     at org.apache.catalina.core.StandardService.start(StandardService.java:516)
     at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
     at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
     at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
    Caused by: java.lang.reflect.InvocationTargetException

    1、核对lib包

    commons-fileupload-1.2.1.jar,
    commons-io-1.3.2.jar
    commons-logging-1.0.4.jar
    freemarker-2.3.16.jar
    ognl-3.0.jar
    struts2-core-2.2.1.jar
    xwork-core-2.2.1.jar

    注意2.1以前是没有commons-fileupload-1.2.1.jar,

    2、如果struts2版本是2.1以前

    web.xml配置过滤器的时候应该是这样:

    <web-app>
    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>

    org.apache.struts2.dispatcher.FilterDispatcher
    </filter-class>
    </filter>
    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    </web-app>


    如果struts2 版本是2.1以上

    web.xml配置

    <web-app>
    <filter>  
    <filter-name>struts2</filter-name>  
    <filter-class>

    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter  
    </filter-class>  
    </filter>  
    <filter-mapping>  
    <filter-name>struts2</filter-name>  
    <url-pattern>/*</url-pattern>  
    </filter-mapping>  
    </web-app>
    3、

    在使用struts-2.2.1时,需要引入javassist-3.7.ga.jar,而这个在struts-2.2.1\lib下是没有的,需要在struts-2.2.1\apps\struts2-blank-2.2.1.war下的lib中找。
    struts.xml文件头是从struts2-2.2.1-all\struts-2.2.1\apps里的任意文件拷贝的!

  • 相关阅读:
    Arrays类
    异常
    Java日志第53天 2020.8.29
    Java日志第52天 2020.8.28
    Java日志第55天 2020.8.31
    Java日志第54天 2020.8.30
    测试:ATM
    dear mother
    Spring
    People like me
  • 原文地址:https://www.cnblogs.com/xiaoxian1369/p/2377381.html
Copyright © 2020-2023  润新知