---
title: "NullPointerException  at com.opensymphony.xwork2.spring.SpringObjectFactory.getC"
author: "cargoj"
date: "2011-06-03T17:23:01Z"
tags: []
categories: ["企业架构"]
slug: "nullpointerexception-at-com-opensymphony-xwork2-spring-springobjectfactory-getc"
draft: false
lastmod: "2011-06-03T17:23:01Z"
id: 1069740
url: "https://cargoj.iteye.com/blog/1069740"
---

at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:209

2010-07-19 18:27

启动服务器时出现异常：

警告: Failed startup of context com.google.apphosting.utils.jetty.DevAppEngineWebAppContext@1242b11{/,E:\\workspace\\uploadPhoto\\war}

Class: com.opensymphony.xwork2.spring.SpringObjectFactory  
File: SpringObjectFactory.java  
Method: getClassInstance  
Line: 209 - com/opensymphony/xwork2/spring/SpringObjectFactory.java:209:-1  
Caused by: java.lang.NullPointerException  at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:209)

原因两个：  
1.lib中多导入包的大原因：去掉struts2-spring-plugin-2.1.8包即可，因为没有用到spring。  
2.还有的原因是用spring了，却没加监听器，在web.xml里面加上  
&lt;listener&gt;  
&lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;  
&lt;/listener&gt;