facebook

Spring-Hibernate: Class-cast exception when retrieving DAO

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 4 posts - 16 through 19 (of 19 total)
  • Author
    Posts
  • #246673 Reply

    Riyad Kalla
    Member

    When you deploy your application and browse to the deployed location and go into the WEB-INF/lib directory, do you see hibernate3.jar there?

    #246706 Reply

    smoyer
    Member

    Thank you for your help. You were correct, it wasn’t there. I fixed that and then got a series of similar errors where there were missing jars. I fixed all of them.

    I am trying to set up a connection to the database with this code in posapp-servlet.xml:

    <bean id=”sessionFactory” class=”org.springframework.orm.hibernate3.LocalSessionFactoryBean”>
    <property name=”dataSource”>
    <ref bean=”dataSource”/>
    </property>
    <property name=”mappingResources”>
    <list>
    <value>User.hbm.xml</value>
    </list>
    </property>
    <property name=”hibernateProperties”>
    <props>
    <prop key=”hibernate.dialect”>org.hibernate.dialect.MySQLDialect</prop>
    </props>
    </property>
    </bean>

    <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/posdprod</value>
    </property>
    <property name=”username”><value>root</value></property>
    <property name=”password”><value>tacoddog</value></property>
    </bean>

    <bean id=”userDao” class=”dataAccess.UserDAO”>
    <property name=”sessionFactory” >
    <ref bean=”sessionFactory”/>
    </property>
    </bean>

    <bean id=”userMan” class=”bus.UserManager”>
    <property name=”userDao”>
    <ref bean=”userDao”/>
    </property>
    </bean>

    Now I am getting this error:

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘posAppController’ defined in ServletContext resource [/WEB-INF/posapp-servlet.xml]: Can’t resolve reference to bean ‘userMan’ while setting property ‘userManager’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userMan’ defined in ServletContext resource [/WEB-INF/posapp-servlet.xml]: Can’t resolve reference to bean ‘userDao’ while setting property ‘userDao’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userDao’ defined in ServletContext resource [/WEB-INF/posapp-servlet.xml]: Can’t resolve reference to bean ‘sessionFactory’ while setting property ‘sessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory’ defined in ServletContext resource [/WEB-INF/posapp-servlet.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: null

    I’m not sure what I need to do now.

    Sue Moyer

    #246713 Reply

    Haris Peco
    Member

    Sue.

    Do you have bean ‘posAppController’ ?

    Best

    #246758 Reply

    smoyer
    Member

    The problem was that I was still missing jars. I added all of the hibernate jars to the class path and the application is now running. Thank you for your help.

    Sue

Viewing 4 posts - 16 through 19 (of 19 total)
Reply To: Spring-Hibernate: Class-cast exception when retrieving DAO

You must be logged in to post in the forum log in