• com/opensymphony/xwork2/spring/SpringObjectFactory.java:220:-1问题出现的原因及解决办法


    转自:https://blog.csdn.net/shinchan_/article/details/37818927

    com/opensymphony/xwork2/spring/SpringObjectFactory.java:220:-1问题出现的原因及解决办法
    严重: Exception starting filter struts2
    Class: com.opensymphony.xwork2.spring.SpringObjectFactory
    File: SpringObjectFactory.java
    Method: getClassInstance
    Line: 220 - com/opensymphony/xwork2/spring/SpringObjectFactory.java:220:-1
     at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:437)
     at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:195)
     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:3709)
     at org.apache.catalina.core.StandardContext.start(StandardContext.java:4356)
     at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
     at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
     at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
     at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
     at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
     at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
     at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1215)
     at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
     at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
     at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
     at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
     at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
     at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
     at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.NullPointerException
     at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:220)
     at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyResultType(XmlConfigurationProvider.java:530)
     at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addResultTypes(XmlConfigurationProvider.java:501)
     at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:457)
     at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:275)
     at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
     at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:204)
     at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
     at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:380)
     at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:424)
     ... 20 more
    2011-8-28 1:19:47 org.apache.catalina.core.StandardContext start
    严重: Error filterStart
    2011-8-28 1:19:47 org.apache.catalina.core.StandardContext start

    严重: Context [] startup failed due to previous errors


    原因一:

          问题处在你导入的“Struts2 Spring Libraries”库下的“Struts2-spring-plugin-2.2.1.jar”jar包下的struts-plugin.xml里。如下图:

           问题出现的具体位置在上图所示的第29行的代码,这段代码如下:

    <bean type="com.opensymphony.xwork2.ObjectFactory" name="spring" class="org.apache.struts2.spring.StrutsSpringObjectFactory" />
           这表明该插件引入工程后,会自动设置Struts的ObjectFactory为StrutsSpringObjectFactory,从而让Spring的IOC容器来托管Struts的Action。但是在工程的web.xml中没有配置加载spring ApplicationContext相关的listener,从而导致了启动时出现的问题:com/opensymphony/xwork2/spring/SpringObjectFactory.java:220:-1。

    原因二及解决方法:

          可能是由于没有用到spring的jar包,而却导入了spring的jar包,从而导致这个错误,将spring没用的jar包删除就可以了;

    二、原因一的解决办法

    在工程的web.xml中配置加载spring ApplicationContext相关的listener,配置的代码如下:

        <context-param>
            <param-name>
                contextConfigLocation
            </param-name>
            <param-value>
                /WEB-INF/applicationContext.xml
            </param-value>
        </context-param>
        <listener>
            <listener-class>
                org.springframework.web.context.ContextLoaderListener
            </listener-class>

        </listener>终于解决了这个小问题,记录一下,方便查看和回顾,也希望能帮到遇到这个问题需要寻求帮助的

    --------------------- 作者:shinchan_ 来源:CSDN 原文:https://blog.csdn.net/shinchan_/article/details/37818927?utm_source=copy 版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    OpenLayers 添加OpenStreetMap(OSM)瓦片层示例
    [转]Net Framework引路蜂地图开发示例
    SVG关注复杂图形的网页绘制技术
    解决Easyui1.3.3 IE8兼容性问题
    Ajax学习教程在线阅读
    判断访问站点的浏览器类型
    修改TOMCAT服务器图标为应用LOGO
    ArcGIS学习推荐基础教程摘录
    Jquery html页面处理基础
    android AppWidget的使用以及利用TimerTask实现widget的定时更新
  • 原文地址:https://www.cnblogs.com/sharpest/p/9770719.html
Copyright © 2020-2023  润新知