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


    报的错误:

     1 严重: Exception starting filter struts2 
     2 Class: com.opensymphony.xwork2.spring.SpringObjectFactory 
     3 File: SpringObjectFactory.java 
     4 Method: getClassInstance 
     5 Line: 220 - com/opensymphony/xwork2/spring/SpringObjectFactory.java:220:-1 
     6  at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:437) 
     7  at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:195) 
     8  at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275) 
     9  at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397) 
    10  at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108) 
    11  at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709) 
    12  at org.apache.catalina.core.StandardContext.start(StandardContext.java:4356) 
    13  at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) 
    14  at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) 
    15  at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) 
    16  at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626) 
    17  at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553) 
    18  at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488) 
    19  at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1215) 
    20  at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293) 
    21  at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) 
    22  at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337) 
    23  at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601) 
    24  at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610) 
    25  at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590) 
    26  at java.lang.Thread.run(Unknown Source) 
    27 Caused by: java.lang.NullPointerException 
    28  at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:220) 
    29  at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyResultType(XmlConfigurationProvider.java:530) 
    30  at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addResultTypes(XmlConfigurationProvider.java:501) 
    31  at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:457) 
    32  at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:275) 
    33  at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111) 
    34  at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:204) 
    35  at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66) 
    36  at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:380) 
    37  at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:424) 
    38  ... 20 more 
    39 2011-8-28 1:19:47 org.apache.catalina.core.StandardContext start 
    40 严重: Error filterStart 
    41 2011-8-28 1:19:47 org.apache.catalina.core.StandardContext start 
    42 严重: 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。  

    二、解决办法

    在工程的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>

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

    原文:http://www.tuicool.com/articles/Mzy2ui

  • 相关阅读:
    韩日网民爆发网络大战 互相攻瘫服务器 狼人:
    2010年RSA大会RSA总裁主题演讲:云的安全 狼人:
    黑客非法下载4千万条学历数据被判刑 狼人:
    黑客称Windows 7比Linux安全 Flash是威胁 狼人:
    方法代码Scala中的语言特性是如何实现的(2)
    参考知识svideo vs. composite video vs. component video 几种视频格式详细说明和比较
    旋转长度左旋转字符串(26)
    设置参数cocos2dx 2.x 进度条CCProgressTimer
    队列输入队列基本操作
    安装华硕华硕电脑K52JU安装银联控件蓝屏
  • 原文地址:https://www.cnblogs.com/xiaochaozi/p/3427020.html
Copyright © 2020-2023  润新知