日期:2014-05-17  浏览次数:20624 次

SessionFactory为空
问题如题,无法获取sessionFactory.控制台没有报错,浏览器报空指针异常.
description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

java.lang.NullPointerException
org.emper.xuanke.dao.impl.UserDaoImpl.validateUser(UserDaoImpl.java:15)
org.emper.xuanke.action.UserAction.execute(UserAction.java:61)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:440)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:279)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
(省略)

项目结构:


/***************************applicationContext.xml************/
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">


<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="jdbc:oracle:thin:@localhost:1521:orcl">
</property>
<property name="username" value="system"></property>
<property name="password" value="123456"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>org/emper/xuanke/vo/Student.hbm.xml</value>
<value>
org/emper/xuanke/vo/Selectedcourse.hbm.xml
</value>
<value>
org/emper/xuanke/vo/Selectivecourse.hbm.xml
</value>
<value>org/emper/xuanke/vo/Usertable.hbm.xml</value></list>
</property>
</bean>


<bean id="userDaoImpl" class="org.emper.xuanke.dao.impl.UserDaoImpl" >
<property name="sessionFactory">
<ref bean="sessionFactory"></ref>
</property>
</bean>

<bean id="userAction" class="org.emper.xuanke.action.UserAction">
<property name="userDaoImpl">
<ref bean="userDaoImpl"/>
</property>
</bean>