-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Spring - Hibernate error
PostPosted: Thu Jul 05, 2007 6:04 am 
Newbie

Joined: Thu Jul 05, 2007 5:58 am
Posts: 2
Hi,

I'm working on the technology of Spring and Hibernate.
I'm getting the following error.

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.HibernateException: Could not instantiate dialect class
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.HibernateException: Could not instantiate dialect class
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:403)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:230)
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:156)
org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:81)
javax.servlet.GenericServlet.init(GenericServlet.java:211)
org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:701)
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:432)
org.apache.catalina.startup.HostConfig.start(HostConfig.java:983)
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
org.apache.catalina.startup.Catalina.start(Catalina.java:556)
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:324)
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287)
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.



[code] - ApplicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
<property name="url"><value>jdbc:mysql://localhost:3306/springregistration</value></property>
<property name="username"><value>root</value></property>
<!-- Make sure <value> tags are on same line - if they're not,
authentication will fail -->
<property name="password"><value>root</value></property>
</bean>
<!-- Hibernate Session Factory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources">
<list>
<value>com/logicamg/mapping/Registration.hbm.xml</value>
</list>
</property>

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">false</prop>
</props>
</property>
</bean>

<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->

<!-- Please Don't touch this -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" abstract="false" singleton="true" lazy-init="default" autowire="default" dependency-check="default">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>

<!-- Here's where the DAO definitions will sit -->
<bean id="registrationDAO" class="com.logicamg.DAO.hibernate.RegistrationDAOHibernate">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<!-- Here's where the service manager definitions will sit -->
<bean id="registrationserviceTarget" class="com.logicamg.services.impl.RegistrationImpl">
<property name="registrationDAO"><ref local="registrationDAO"/></property>
</bean>

<!-- Here is where the connection between service manager and tranasaction manager will sit -->
<bean id="registrationservice"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref local="transactionManager"/></property>
<property name="target"><ref local="registrationserviceTarget"/></property>

<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_SUPPORTS</prop>
</props>
</property>
</bean>
</beans>


[/code]


Top
 Profile  
 
 Post subject: Re: Spring - Hibernate error
PostPosted: Thu Jul 05, 2007 9:10 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
Deepa Venkatraman wrote:
Code:
- ApplicationContext.xml
...
   
<!-- Hibernate Session Factory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

...

            <prop key="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</prop>

...



you imply you are using hibernate3 by the Spring SessionFactory package but your dialect class references the old hibernate2 package name.

change it to org.hibernate.dialect.MySQLDialect

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject: Getting the new error
PostPosted: Tue Jul 10, 2007 2:35 am 
Newbie

Joined: Thu Jul 05, 2007 5:58 am
Posts: 2
After I changed to "org.hibernate.dialect.MySQLDialect". But now I'm getting this error.

javax.servlet.ServletException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: entity class not found: com.logicamg.mapping.Registration
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: entity class not found: com.logicamg.mapping.Registration
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:403)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:230)
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:156)
org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:81)
javax.servlet.GenericServlet.init(GenericServlet.java:211)
org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:701)
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:432)
org.apache.catalina.startup.HostConfig.start(HostConfig.java:983)
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
org.apache.catalina.startup.Catalina.start(Catalina.java:556)
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:324)
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287)
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425)


Top
 Profile  
 
 Post subject: Re: Getting the new error
PostPosted: Tue Jul 10, 2007 8:09 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
Deepa Venkatraman wrote:
entity class not found: com.logicamg.mapping.Registration


ok. fix that problem. make sure your hbm.xml files are moved to your build folder, or classpath is broken, or whatever.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.