Announcement Announcement Module
Collapse
No announcement yet.
Exception while creating session Factory bean instance Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception while creating session Factory bean instance

    Hi,

    Following is my xml file:

    <bean id="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName">
    <value>com.mysql.jdbc.Driver</value>
    </property>
    <property name="url">
    <value>jdbc:mysql://localhost:3306/jmobile_portal</value>
    </property>
    </bean>
    <bean id="portalSessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <!-- Echo all executed SQL to stdout -->
    <property name="dataSource">
    <ref bean="dataSource"/>
    </property>
    <property name="hibernateProperties">
    <ref bean="portalHibernateProperties" />
    </property>
    <!-- OR mapping files. -->
    <property name="mappingResources">
    <list>
    <value>"com.jmobiles.businessmodel.AdminUsersModel "</value>
    <value>"com.jmobiles.businessmodel.ContentParamete rModel"</value>
    <value>"com.jmobiles.businessmodel.ContentModel" </value>
    <value>"com.jmobiles.businessmodel.ContentObjectMo del"</value>

    </list>
    </property>
    </bean>
    <bean singleton="true" id="contentObjectDAO" class="com.jmobiles.daos.ContentObjectDAO">
    <property name="sessionFactory"><ref bean="portalSessionFactory"/></property>
    </bean>

    <bean id="portalHibernateProperties"
    class="org.springframework.beans.factory.config.Pr opertiesFactoryBean">
    <property name="properties">
    <props>
    <prop key="hibernate.hbm2ddl.auto">update</prop>
    <prop
    key="hibernate.dialect">net.sf.hibernate.dialect.D erbyDialect</prop>
    <prop
    key="hibernate.query.substitutions">true 'T', false 'F'</prop>
    <prop key="hibernate.show_sql">false</prop>
    <prop key="hibernate.c3p0.minPoolSize">2</prop>
    <prop key="hibernate.c3p0.maxPoolSize">20</prop>
    <prop key="hibernate.c3p0.timeout">600</prop>
    <prop key="hibernate.c3p0.max_statement">50</prop>
    <prop
    key="hibernate.c3p0.testConnectionOnCheckout">fals e</prop>
    </props>
    </property>
    </bean>


    and exception is

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'portalSessionFactory' defined in ServletContext resource [/WEB-INF/jmobiles-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: net/sf/hibernate/HibernateException
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:370)
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:226)


    Please can anyone help me out:

    Regards,

    Shahzad

  • #2
    You don't have HB inside your classpath (or you have an older version).

    Comment


    • #3
      hibernate3.jar and hibernate-annotations.jar

      Originally posted by costin
      You don't have HB inside your classpath (or you have an older version).

      I have hibernate3.jar(1819 kb) and hibernate-annotations.jar(192 kb) in my class path.

      Regards,

      Shahzad

      Comment


      • #4
        net/sf/hibernate/ is the package for HB2 - org.hibernate is for HB3. Also you have to modify the spring classes for hb3 (org.springframework.hibernate - hb2 support, org.springframework.hibernate3 - hb3 support).

        Comment


        • #5
          Then you need to be using the Hibernate 3 classes.

          Code:
           <bean id="portalSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
          Code:
           <prop key="hibernate.dialect">org.hibernate.dialect.DerbyDialect</prop>
          Bob

          Comment


          • #6
            Thanx man one more problem

            Originally posted by Cowboy Bob
            Then you need to be using the Hibernate 3 classes.

            Code:
             <bean id="portalSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            Code:
             <prop key="hibernate.dialect">org.hibernate.dialect.DerbyDialect</prop>
            Bob

            How can i tell about mapping my Model classes in this xml as i am using annotations.

            regards,

            Shahzad

            Comment


            • #7
              Originally posted by shahzad992
              How can i tell about mapping my Model classes in this xml as i am using annotations.

              regards,

              Shahzad
              No idea, I haven't had the opportunity to use annotations. Sorry.

              Bob

              Comment


              • #8
                MAN I have done it

                Originally posted by Cowboy Bob
                No idea, I haven't had the opportunity to use annotations. Sorry.

                Bob

                <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotati on.AnnotationSessionFactoryBean">
                <property name="dataSource">
                <ref bean="dataSource"/>
                </property>
                <property name="annotatedClasses">
                <list>
                <value>com.jmobiles.businessmodel.AdminUsersMode l</value>
                <value>com.jmobiles.businessmodel.ContentParameter Model</value>
                <value>com.jmobiles.businessmodel.ContentModel</value>
                <value>com.jmobiles.businessmodel.ContentObjectMod el</value>
                </list>
                </property>
                </bean>

                Comment

                Working...
                X