Announcement Announcement Module
Collapse
No announcement yet.
Error creating bean with name 'sessionFactory' Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error creating bean with name 'sessionFactory'

    Hi Everyone,

    I am trying to use Hibernate in my web app. But when I start the resin server I get an error stating:

    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in resource [/WEB-INF/simpleapp-servlet.xml] of ServletContext: Initialization of bean failed; nested exception is java.lang.NullPointerException: null
    java.lang.NullPointerException
    	at net.sf.hibernate.cfg.Binder.getTypeFromXML(Binder.java:888)
    	at net.sf.hibernate.cfg.Binder.bindSimpleValue(Binder.java:403)
    	at net.sf.hibernate.cfg.Binder.bindListSecondPass(Binder.java:1068)
    	at net.sf.hibernate.cfg.Binder$ListSecondPass.secondPass(Binder.java:1357)
    	at net.sf.hibernate.cfg.Binder$SecondPass.doSecondPass(Binder.java:1303)
    	at net.sf.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:589)
    	at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:732)
    	at org.springframework.orm.hibernate.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:467)
    	at org.springframework.orm.hibernate.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:405)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:991)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:288)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:208)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:136)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:224)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:284)
    	at org.springframework.web.context.support.XmlWebApplicationContext.refresh(XmlWebApplicationContext.java:131)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:282)
    	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:230)
    	at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:200)
    	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:102)
    	at javax.servlet.GenericServlet.init(GenericServlet.java:82)
    	at com.caucho.server.http.Application.createServlet(Application.java:3109)
    	at com.caucho.server.http.Application.loadServlet(Application.java:3060)
    	at com.caucho.server.http.Application.initServlets(Application.java:1921)
    	at com.caucho.server.http.Application.init(Application.java:1847)
    	at com.caucho.server.http.VirtualHost.init(VirtualHost.java:728)
    	at com.caucho.server.http.ServletServer.initHosts(ServletServer.java:874)
    	at com.caucho.server.http.ServletServer.initInternal(ServletServer.java:719)
    	at com.caucho.server.http.ServletServer.init(ServletServer.java:530)
    	at com.caucho.server.http.ResinServer.init(ResinServer.java:393)
    	at com.caucho.server.http.ResinServer.main(ResinServer.java:1154)
    	at com.caucho.server.http.HttpServer.main(HttpServer.java:103)
    My simpleapp-servlet.xml looks like this:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    	<!-- ****************** DB Connection Config *************** -->
    	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    		<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
    		<property name="url"><value>jdbc&#58;mysql&#58;//localhost/simpleapp</value></property>
    		<property name="username"><value>simpleapp</value></property>
    		<property name="password"><value>simpleapp</value></property>
    	</bean>
    	
    	<!-- ******************* Hibernate DAO Config ********************* -->	
    	<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    		
    		<property name="mappingResources">
    			<list>				
    				<value>simpleapp/model/Roles.hbm.xml</value>
    				<value>simpleapp/UserHead.hbm.xml</value>
    			</list>
    		</property>
    		
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</prop>
    				<prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
    				<prop key="hibernate.show_sql_query">true</prop>
    				<prop key="hibernate.use_outer_join">false</prop>
    			</props>
    		</property>
    		
    		<property name="dataSource">
    			<ref bean="dataSource"/>
    		</property>
    	</bean>	
    
    	<!-- ******************* DAO Classes ******************************-->
    	<bean id="userAdminDAOImpl" class="simpleapp.database.impl.UserAdminDAOImpl">
    		<property name="sessionFactory">
    			<ref bean="sessionFactory"/>			
    		</property>
    	</bean>
    
    	<!-- ******************* Supporter Class for Controllers ************** -->
    	<bean id="addUserValidator" class="simpleapp.validator.AddUserValidator"/>
    	
    	<!-- ******************* Application Controller Config ********** -->	
    	<bean id="addUserController" class="simpleapp.controller.AddUserController">
    		<property name="validator">
    			<ref bean="addUserValidator" />
    		</property>
    		
    		<property name="commandClass">
    			<value>simpleapp.adapter.AddUserAdapter</value>
    		</property>
    		
    		<property name="userAdminDAOImpl">
    			<ref bean="userAdminDAOImpl"/>
    		</property>
    
    		<property name="formView"><value>addUserForm</value></property>
    		<property name="successView"><value>addUserForm</value></property>
    	</bean>
    	
    	<!-- ******************* Basic Resources Config ***************** -->
    	<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
    		<property name="basename">
    			<value>views</value>
    		</property>
    	</bean>
    	
    	<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    		<property name="basename">
    			<value>messages</value>
    		</property>
    	</bean>
    	
    	<bean id="urlMappings" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="mappings">
    			<props>
    				<prop key="/addUsers.spf">addUserController</prop>
    			</props>
    		</property>
    	</bean>	
    </beans>
    What is the wrong with above XML file. I am using Resin 2.1.8, Hibernate 2.1.1 & MySQL 4.1.7.

  • #2
    it seems to be a classpath error

    hope it helps

    Comment

    Working...
    X