Announcement Announcement Module
Collapse
No announcement yet.
spring data jpa 1.2.0 and jpa:repositories Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring data jpa 1.2.0 and jpa:repositories

    Hello,

    With a project using Spring 3.1.3 and Spring DM 1.2.1, when I update Spring Data JPA from version 1.1.2 to 1.2.0 (and Spring Data Commons Core from 1.3.2 to 1.4.0), then the element jpa:repositories stops to generate the repository proxies for the selected interfaces.
    Any attempt to uses such proxy generates an exception such as:
    Code:
     
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#0': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Cannot locate bean named 'userDao' inside the running bean factory.
    Any idea to solve this issue?

    Regards
    Pierre

    Herewith a zip file of a minimal test project under Eclipse. EclipseLink 2.4.1 and Derby 10.9.1 are used.
    Below the project's context and manifest and the full trace of the exception.

    context configuration
    Code:
        <bean id="dataSourcePropertyConfigurer"
            class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="ignoreUnresolvablePlaceholders" value="true"/>
            <property name="locations">
                <list>
                    <value>classpath:derby.properties</value>
                </list>
             </property>
        </bean>
     
        <bean id="dataSource" 
            class="org.apache.commons.dbcp.BasicDataSource"
            p:driverClassName="${database.driverClassName}" 
            p:url="${database.url}" 
            p:initialSize="5" 
            p:maxActive="50" 
            init-method="createDataSource" 
            destroy-method="close" />
     
        <bean id="jpaPropertyConfigurer"
            class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="properties">
                <props>
                    <prop key="database.label">DERBY</prop>
                    <prop key="database.script.path">target/derbydb/</prop>
                </props>
            </property>
        </bean>        
      
        <bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
    
        <bean id="jpaProperties"
            class="org.springframework.beans.factory.config.PropertiesFactoryBean">
            <property name="properties">
                <props>
                    <prop key="eclipselink.ddl-generation">drop-and-create-tables</prop>
                    <prop key="eclipselink.ddl-generation.output-mode">both</prop>
                    <prop key="eclipselink.target-database">${database.label}</prop>
                    <prop key="eclipselink.weaving">false</prop>
                    <prop key="eclipselink.create-ddl-jdbc-file-name">${database.script.path}create_ddl.sql</prop>
                    <prop key="eclipselink.drop-ddl-jdbc-file-name">${database.script.path}drop_ddl.sql</prop>
                </props>
            </property>
        </bean>
    
        <bean id="jpaVendorAdapter" 
             class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
              <property name="database" value="DERBY" />         
        </bean>
    		
    	<bean id="entityManagerFactory"
    		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    		<property name="persistenceUnitName" value="userUnit" />
    		<property name="dataSource"       ref="dataSource" />
    		<property name="jpaProperties"    ref="jpaProperties" />
    		<property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
    	</bean>
    
    	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
    		p:entityManagerFactory-ref="entityManagerFactory">
    	</bean>
    
    	<tx:annotation-driven transaction-manager="transactionManager" />
    	<jpa:repositories base-package="fr.opensagres.dao">
    		<jpa:repository id="userDao" />
    	</jpa:repositories>
    
        <osgi:service ref="userDao" interface="fr.opensagres.dao.UserDao" />
    Manifest
    Code:
    Manifest-Version: 1.0
    Bundle-ManifestVersion: 2
    Bundle-Name: 120
    Bundle-SymbolicName: essai.jpa.data.120
    Bundle-Version: 1.0.0.qualifier
    Import-Package: javax.persistence;resolution:=optional,
     javax.persistence.criteria,
     javax.persistence.metamodel,
     javax.persistence.spi,
     javax.xml.bind.annotation;resolution:=optional,
     org.aopalliance.aop,
     org.aopalliance.intercept,
     org.apache.commons.dbcp,
     org.apache.derby.jdbc,
     org.springframework.aop,
     org.springframework.aop.aspectj,
     org.springframework.aop.aspectj.annotation,
     org.springframework.aop.aspectj.autoproxy,
     org.springframework.aop.config,
     org.springframework.aop.framework,
     org.springframework.aop.framework.adapter,
     org.springframework.aop.framework.autoproxy,
     org.springframework.aop.framework.autoproxy.target,
     org.springframework.aop.interceptor,
     org.springframework.aop.scope,
     org.springframework.aop.support,
     org.springframework.aop.support.annotation,
     org.springframework.aop.target,
     org.springframework.aop.target.dynamic,
     org.springframework.beans,
     org.springframework.beans.factory,
     org.springframework.beans.factory.config,
     org.springframework.data.domain,
     org.springframework.data.jpa.domain,
     org.springframework.data.jpa.domain.support,
     org.springframework.data.jpa.repository,
     org.springframework.data.jpa.repository.support,
     org.springframework.data.jpa.repository.utils,
     org.springframework.data.repository,
     org.springframework.data.repository.core,
     org.springframework.data.repository.core.support,
     org.springframework.data.repository.query,
     org.springframework.data.repository.query.parser,
     org.springframework.orm,
     org.springframework.orm.jpa,
     org.springframework.orm.jpa.vendor
    Bundle-RequiredExecutionEnvironment: JavaSE-1.6
    Require-Bundle: org.eclipse.persistence.antlr,
     org.eclipse.persistence.asm,
     org.eclipse.persistence.core,
     org.eclipse.persistence.jpa,
     org.eclipse.persistence.jpa.jpql,
     org.eclipse.persistence.jpa.osgi,
     org.springframework.aop;bundle-version="3.1.3",
     org.springframework.asm;bundle-version="3.1.3",
     org.springframework.beans;bundle-version="3.1.3",
     org.springframework.context;bundle-version="3.1.3",
     org.springframework.core;bundle-version="3.1.3",
     org.springframework.data.core;bundle-version="1.3.2",
     org.springframework.data.jpa;bundle-version="1.1.2",
     org.springframework.expression;bundle-version="3.1.3",
     org.springframework.jdbc;bundle-version="3.1.3",
     org.springframework.orm;bundle-version="3.1.3",
     org.springframework.osgi.core;bundle-version="1.2.1",
     org.springframework.osgi.extender;bundle-version="1.2.1",
     org.springframework.osgi.io;bundle-version="1.2.1",
     org.springframework.transaction;bundle-version="3.1.3"
    Trace
    Code:
    2296 [SpringOsgiExtenderThread-2] ERROR org.springframework.osgi.extender.internal.activator.ContextLoaderListener  - Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=essai.jpa.data.120, config=osgibundle:/META-INF/spring/*.xml))
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#0': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Cannot locate bean named 'userDao' inside the running bean factory.
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:587)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
    	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
    	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
    	at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
    	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
    	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
    	at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.IllegalArgumentException: Cannot locate bean named 'userDao' inside the running bean factory.
    	at org.springframework.util.Assert.isTrue(Assert.java:65)
    	at org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean.afterPropertiesSet(OsgiServiceFactoryBean.java:163)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
    	... 14 more

  • #2
    We've removed the <jpa:repository /> element in 1.2.0 so it's hard to believe the setup as you show it here actually makes it to the exception. I've quickly tried to give the sample project a try but it doesn't even compile for me.

    Comment

    Working...
    X