• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error in sessionFactory

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For some weird reason my appln tries to access hibernate2???
I use eclipse andhave added hibernate3 as my external jar.....
I get the following error

INFO: closing
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shoppingCartTarget' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: net/sf/hibernate/SessionFactory
java.lang.NoClassDefFoundError: net/sf/hibernate/SessionFactory
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getDeclaredMethods(Unknown Source)
at java.beans.Introspector$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.beans.Introspector.getPublicDeclaredMethods(Unknown Source)
at java.beans.Introspector.getTargetMethodInfo(Unknown Source)
at java.beans.Introspector.getBeanInfo(Unknown Source)
at java.beans.Introspector.getBeanInfo(Unknown Source)
at java.beans.Introspector.getBeanInfo(Unknown Source)
at java.beans.Introspector.<init>(Unknown Source)
at java.beans.Introspector.getBeanInfo(Unknown Source)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:150)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:87)
at org.springframework.beans.BeanWrapperImpl.setIntrospectionClass(BeanWrapperImpl.java:237)
at org.springframework.beans.BeanWrapperImpl.setWrappedInstance(BeanWrapperImpl.java:195)
at org.springframework.beans.BeanWrapperImpl.setWrappedInstance(BeanWrapperImpl.java:179)
at org.springframework.beans.BeanWrapperImpl.<init>(BeanWrapperImpl.java:132)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:487)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:362)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:283)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:87)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:72)
at ShoppingClient.main(ShoppingClient.java:19)


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

<!-- Application context definition for Subscriptions on Hibernate -->
<beans>


<!-- ========================= RESOURCE DEFINITIONS ========================= -->

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="maxActive"><value>20</value></property>
<property name="maxIdle"><value>10</value></property>
<property name="maxWait"><value>10000</value></property>
<property name="username"><value>root</value></property>
<property name="password"><value>priya123</value></property>
<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
<property name="url"><value>jdbc:mysql://localhost/hibernateSample</value></property>
<!--property name="url"><value>jdbc:mysql://192.168.47.3/DocLog</value></property-->
</bean>

<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>ShoppingCart.hbm.xml</value>
<value>ShoppingItem.hbm.xml</value>
<value>Manufacturer.hbm.xml</value>
</list>
</property>
</bean>


<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->


<!-- Pass the session factory to our UserDAO -->
<bean id="shoppingCartTarget" class="ShoppingCartImpl">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>


<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref bean="sessionFactory"/></property>
</bean>






</beans>
 
subu ananthram
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmmm really stupid mistake I had imported hibernate2 and not 3
mport org.springframework.orm.hibernate3.support.HibernateDaoSupport;
in my class
reply
    Bookmark Topic Watch Topic
  • New Topic