Hi there,

I'm using spring MVC framework to create an application in which i need to integrate Hibernate with SPRING MVC .I tried a lot but unable to connect to database.All the times it's throwing an exception.
Here is the trace:

org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'hibernateTemplate' defined in ServletContext resource [/WEB-INF/springweb-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.springframework.orm.hibernate3.LocalSessionFac toryBean] to required type [org.hibernate.SessionFactory] for property 'sessionFactory'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.springframework.orm.hibernate3.LocalSessionFac toryBean] to required type [org.hibernate.SessionFactory] for property 'sessionFactory': no matching editors or conversion strategy found
org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:480)
org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
java.security.AccessController.doPrivileged(Native Method)
org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:221)
org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:429)
org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:729)
org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:381)
org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 02)
org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:316 )
org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:282)
org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:126)
javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:212)
org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:818)
org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:624)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:445)
java.lang.Thread.run(Unknown Source)


my spring configuration file is as follows:
springweb-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<bean name="homePage" class="HomePageController" />

<bean id="login" class="LoginFormController">
<property name="formView" value="loginForm" />
<property name="successView" value="loginSuccessful" />
<property name="commandName" value="loginForm" />
<property name="commandClass" value="LoginForm" />
<property name="loginDao">
<ref bean="loginDao" />
</property>
</bean>

<bean id="viewResolver"
class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
<property name="prefix" value="/jsp/" />
<property name="suffix" value=".jsp" />
</bean>

<bean id="simpleUrlMapping"
class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/home.do">homePage</prop>
<prop key="/login.do">login</prop>
</props>
</property>
</bean>

<bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource" >
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost/test"/>
<property name="username" value="root"/>
<property name="password" value="test"/>
</bean>

<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
<property name="dataSource" ref="myDataSource"/>
<property name="mappingResources">
<list>
<value>springweb.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>hibernate.dialect=org.hibernate.dialect.H SQ LDialect</value>
</property>
</bean>

<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.Hibernat eTemplate">
<property name="sessionFactory">
<ref bean="mySessionFactory"/>
</property>
</bean>

<bean id="loginDao" class="LoginForm">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate"/>
</property>
</bean>

</beans>


Here is another hibernate cofiguration file:
springweb.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>

<hibernate-mapping>
<class name="LoginForm" table="login_table">
<id name="id" column="Id">
<generator class="assigned" />
</id>

<property name="userName">
<column name="username" />
</property>
<property name="password">
<column name="password" />
</property>
</class>
</hibernate-mapping>

here is the implemantation of dao:
public class LoginDao {
private HibernateTemplate hibernateTemplate;

public void setHibernateTemplate(HibernateTemplate hibernateTemplate){
this.hibernateTemplate = hibernateTemplate;
}

public HibernateTemplate getHibernateTemplate(){
return hibernateTemplate;
}

public void saveOrUpdate(final LoginForm loginForm){
HibernateCallback callback = new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException,SQLException {
session.save(loginForm);
return null;
}
};
hibernateTemplate.execute(callback);
}
}
can anyone please help me what i am am doing wrong here.
Thanks in advance .
Please reply ASAP.

Thanks:
Bhawani