com/opensymphony/xwork2/spring/SpringObjectFactory

严重: 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里。如下图:

com/opensymphony/xwork2/spring/SpringObjectFactory_第1张图片

问题出现的具体位置在上图所示的第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。

解决办法是不要导入    struts2-spring-plugin-2.3.16.1.jar 包

就是这么简单,等需要用的时候在导入spring包。说句实话,用ssm(ssh)开发配置实在是太麻烦了。

你可能感兴趣的:(com/opensymphony/xwork2/spring/SpringObjectFactory)