Announcement Announcement Module
Collapse
No announcement yet.
Upgrade from 2.0rc3 to 2.0final causes "Could not instantiate connection provider" Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Upgrade from 2.0rc3 to 2.0final causes "Could not instantiate connection provider"

    I'm trying to upgrade from Spring 2.0rc3 to Spring 2.0final and I'm having trouble with regard to the Hibernate 3 + JPA setup. This is occuring during unit tests - i.e. this is not running in a servlet container.

    When I switch back to the rc3 jars, all is well.

    Here's what I believe is the pertinent context file bits (the stack trace is at the bottom of the post):
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="
           http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
    
      <bean id="entityManagerFactory"
        class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="jpaVendorAdapter">
          <bean
            class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="showSql" value="true" />
            <property name="generateDdl" value="true" />
            <property name="databasePlatform"
              value="org.hibernate.dialect.MySQLDialect" />
          </bean>
        </property>
        <property name="loadTimeWeaver">
          <bean
            class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver" />
        </property>
      </bean>
    
      <bean id="transactionManager"
        class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory" />
      </bean>
     
      <tx:advice id="txAdvice">
        <tx:attributes>
          <tx:method name="create*"/>
          <tx:method name="read*" read-only="true"/>
          <tx:method name="update*"/>
          <tx:method name="delete*"/>
        </tx:attributes>
      </tx:advice>
    
      <aop:config>
        <aop:pointcut id="serviceMethods"
          expression="execution(* myapp.service.*.*(..))" />
        <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethods" />
      </aop:config>
    I get the following stack trace when I try to create an application context:

    Code:
    Error creating bean with name 'entityManagerFactory' defined in URL [file:/<snip>.....</snip>/dao/jpa/AbstractJpaDaoTest.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Could not instantiate connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [file:/<snip>.....</snip>/dao/jpa/AbstractJpaDaoTest.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Could not instantiate connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
    Caused by: org.hibernate.HibernateException: Could not instantiate connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
    	at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:77)
    	at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
    	at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:61)
    	at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1928)
    	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
    	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:631)
    	at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:760)
    	at org.hibernate.ejb.Ejb3Configuration.createContainerEntityManagerFactory(Ejb3Configuration.java:350)
    	at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:119)
    	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:199)
    	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:237)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1029)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:420)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:246)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:128)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:955)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:729)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:416)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:290)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)

  • #2
    I got the same problem. Everything works though, if i define the datasource inside the persistence.xml and use the LocalEntityManagerFactoryBean that simply uses the persistence unit defined in persistence.xml instead of the LocalContainerEntityManagerFactoryBean. But of course thats not what i want because i'd like to run the application on different datasources and dont want to change the persistence.xml in the persistence.jar each time...

    Comment


    • #3
      After browsing the forum some more i found the following post:
      http://forum.springframework.org/sho...55&postcount=9

      And indeed, removing the load time weaver from thar EntityManagerFactoryBean does the trick. Spring + Hibernate + JPA is working now

      Comment


      • #4
        Removing LoadTimeWeaver fixed it

        Thanks for the heads up - your advice did it!

        Just to state it again, I removed the following from my entityManagerFactory bean:

        Code:
            <property name="loadTimeWeaver">
              <bean
                class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver" />
            </property>
        After commenting that out, the issue mentioned above went away.

        However, I did then run into an issue dealing with CGLIB and it trying to create a proxy of a proxy (http://forum.springframework.org/showthread.php?t=10052).
        The new exception looked like this:

        Code:
        java.lang.IllegalArgumentException: Cannot subclass final class class $Proxy3
        I was able to get rid of this exception by omitting the setting of the "proxyTargetClass" property in the definition of a BeanNameAutoProxyCreator being used (I am using the pre-Spring 2.0 method of delcaring AOP proxies). If you're using the new "<aop:config" syntax, I believe the pertinent part of the configuration to leave out would be the "proxy-target-class" so that your <aop:config element would look like:
        Code:
        <aop:config>
        	
        	...
        	
        </aop:config>
        as seen here: http://static.springframework.org/sp...p.html#d0e9015

        Not even sure these issues are related, but I hope this helps someone

        Comment

        Working...
        X