Announcement Announcement Module
Collapse
No announcement yet.
org.springframework.beans.factory.BeanCreationExce ption Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • org.springframework.beans.factory.BeanCreationExce ption

    Hi Everyone,

    Hopefully I am raising this question in the right forum, I am trying to setup the Spring Hibernate Environment for my project, I am keep on getting this error, I guess there is some JAR missing or any compatibility issue. Please suggest if it rings a bell. Details are given below;


    ApplicationContext.xml
    ==================

    Code:
    <beans  
    
        <!-- (in this case, JDBC-related settings for the dataSource definition below) -->  
        <context:property-placeholder location="classpath:jdbc.properties" />  
        <!--  
            Uses Apache Commons DBCP for connection pooling. See Commons DBCP documentation  
            for the required JAR files. Alternatively you can use another connection pool  
            such as C3P0, similarly configured using Spring.  
        -->  
        <bean  
            id="dataSource"  
            class="org.apache.commons.dbcp.BasicDataSource"  
            destroy-method="close"  
            p:driverClassName="${jdbc.driverClassName}"  
            p:url="${jdbc.url}"  
            p:username="${jdbc.username}"  
            p:password="${jdbc.password}" />  
          
        <!-- Hibernate SessionFactory -->  
        <bean  
            id="sessionFactory"  
            class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"  
            p:dataSource-ref="dataSource">  
            <property name="mappingResources">  
                <list>                  
                    <value>user.hbm.xml</value>  
                    <value>role.hbm.xml</value>   
                </list>  
            </property>  
            <property name="hibernateProperties">  
                <props>  
                    <prop key="hibernate.dialect">${hibernate.dialect}</prop>  
                    <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>  
                    <prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop>  
                </props>  
            </property>  
            <property name="eventListeners">  
                <map>  
                    <entry key="merge">  
                        <bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener" />  
                    </entry>  
                </map>  
            </property>  
        </bean>  
        <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->  
        <bean  
            id="transactionManager"  
            class="org.springframework.orm.hibernate3.HibernateTransactionManager"  
            p:sessionFactory-ref="sessionFactory" />  
        <!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->  
        <!--  
            <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>  
        -->  
        <!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->    
    
        <bean  
            id="inventoryServiceDao"  
            class="com.wondergas.inventory.dataaccesstier.InventoryServiceDaoImpl"  
            p:sessionFactory-ref="sessionFactory" />  
          
    </beans>
    Dependencies
    ===========

    http://i976.photobucket.com/albums/a...pendencies.jpg

    Stack Trace
    =========

    Code:
    junit.framework.AssertionFailedError: Exception in constructor: testAddItem (org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot create inner bean '(inner bean)' of type [org.springframework.transaction.interceptor.TransactionInterceptor] while setting bean property 'transactionInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/SessionFactory  
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:445)  
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:383)  
        at java.security.AccessController.doPrivileged(Native Method)  
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:353)  
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)  
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)  
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)  
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)  
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:400)  
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:736)  
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)  
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:123)  
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:76)  
        at com.wondergas.inventory.tests.TestInventoryService.<init>(TestInventoryService.java:29)  
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)  
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)  
        at java.lang.reflect.Constructor.newInstance(Unknown Source)  
        at junit.framework.TestSuite.createTest(TestSuite.java:61)  
        at junit.framework.TestSuite.addTestMethod(TestSuite.java:283)  
        at junit.framework.TestSuite.<init>(TestSuite.java:146)  
        at org.junit.internal.runners.JUnit38ClassRunner.<init>(JUnit38ClassRunner.java:71)  
        at org.junit.internal.builders.JUnit3Builder.runnerForClass(JUnit3Builder.java:14)  
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)  
        at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)  
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)  
        at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)  
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:32)  
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)  
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41)  
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31)  
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)  
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)  
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)  
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)  
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot create inner bean '(inner bean)' of type [org.springframework.transaction.interceptor.TransactionInterceptor] while setting bean property 'transactionInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/SessionFactory  
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:230)  
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122)  
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1172)  
        at  org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:219)  
        ... 53 more  
    Caused by: java.lang.NoClassDefFoundError: org/hibernate/SessionFactory  
        at java.lang.Class.getDeclaredConstructors0(Native Method)  
        at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)  
        at java.lang.Class.getDeclaredConstructors(Unknown Source)  
        at

  • #2
    isn't the exception sufficient - "java.lang.NoClassDefFoundError: org/hibernate/SessionFactory..." you are missing hibernate from your classpath...

    Comment

    Working...
    X