You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Daniel McGreal <da...@redbite.com> on 2014/01/27 17:52:30 UTC

Spring Data JPA

Hi,

I’m investigating moving from Virgo to Karaf. My application uses Spring Data, initially with JPA using EclipseLink.

My strategy so far has resulted in:
Caused by: java.lang.IllegalArgumentException: class org.eclipse.persistence.jpa.osgi.PersistenceProvider is not assignable to interface javax.persistence.spi.PersistenceProvider
	at org.springframework.util.Assert.isAssignable(Assert.java:368)
	at org.springframework.util.Assert.isAssignable(Assert.java:351)
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.setPersistenceProviderClass(AbstractEntityManagerFactoryBean.java:128)
	at com.redbite.redbox.persistence.repository.jpa.configuration.JpaPersistenceConfiguration.entityManagerFactory(JpaPersistenceConfiguration.java:42)
	at com.redbite.redbox.persistence.repository.jpa.configuration.JpaPersistenceConfiguration$$EnhancerByCGLIB$$3c404459.CGLIB$entityManagerFactory$1(<generated>)
	at com.redbite.redbox.persistence.repository.jpa.configuration.JpaPersistenceConfiguration$$EnhancerByCGLIB$$3c404459$$FastClassByCGLIB$$b6dd4002.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:285)
	at com.redbite.redbox.persistence.repository.jpa.configuration.JpaPersistenceConfiguration$$EnhancerByCGLIB$$3c404459.entityManagerFactory(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:160)
	... 17 more

It looks like the class of the spi interface is not the same class that the EclipseLink class has extended, possibly due to multiple versions of bundles?

I wonder if my strategy can be improved:

I use Maven copy-dependencies to populate Karaf's deploy directory, this includes Spring 3.1.4.RELEASE bundles (I haven’t installed them using features) and EclipseLink, Spring Data (& JPA) and their dependencies, e.g. CGLib & AopAlliance bundles.
I install spring-dm manually (if I installed it using Karaf’s features it starts loading things from a Spring 3.2.4.RELEASE context somehow), e.g. installing each featured bundle and setting its start-level to 30 manually.
I deploy my spring bundle which configures a DataSource and LocalContainerEntityManagerFactoryBean as beans using JavaConfig.

I don’t think I’m doing this the “Karaf Way” and wonder how it can be improved? I’m not tied to EclipseLink, and could happily use e.g. OpenJPA.

Thanks for any help you can offer, 
Dan.

Re: Spring Data JPA

Posted by Henryk Konsek <he...@gmail.com>.
Hi Daniel,

> I'm investigating moving from Virgo to Karaf. My application uses Spring
> Data, initially with JPA using EclipseLink.

Here are some of the reference examples I use when working with the
customers. All of them have working Pax Exam tests verifying the
setup.

a) Blueprint + EclipseLink -
https://github.com/hekonsek/fuse-pocs/tree/master/fuse-pocs-blueprint-eclipselink
b) Blueprint + OpenJPA + Spring Data JPA -
https://github.com/hekonsek/fuse-pocs/tree/master/fuse-pocs-blueprint-openjpa-springdata

Cheers.

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com

Re: Spring Data JPA

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi Dan,

I suspect you're using Karaf 3.0, cause there is an issue with the OpenJPA
feature (unfortunately).
I suggest you define the OpenJPA feature yourself based on the fix we have
in Karaf 3.0.1-SNAPSHOT [1]. Or use the latest 3.0.1-SNAPSHOT as basis, it
already got some nice fixes for certain issues.

regards, Achim

[1] -
https://github.com/apache/karaf/blob/master/assemblies/features/enterprise/src/main/feature/feature.xml#L50


2014/1/27 Daniel McGreal <da...@redbite.com>

> Hi again,
>
> I started using Karaf features for the Spring dependencies and OpenJPA.
>
> I now have an OpenJPA error:
> Exception in thread "SpringOsgiExtenderThread-2"
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean with name 'itemRepository': Injection of persistence dependencies
> failed; nested exception is <openjpa-2.3.0-r422266:1540826 nonfatal general
> error> org.apache.openjpa.util.GeneralException: Resource does not exist:
> bundle://143.10:1
> at
> org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:343)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
> 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:589)
> 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:722)
> Caused by: <openjpa-2.3.0-r422266:1540826 nonfatal general error>
> org.apache.openjpa.util.GeneralException: Resource does not exist:
> bundle://143.10:1
> at
> org.apache.openjpa.meta.AbstractCFMetaDataFactory.getPersistentTypeNames(AbstractCFMetaDataFactory.java:635)
> at
> org.apache.openjpa.meta.MetaDataRepository.getPersistentTypeNamesInternal(MetaDataRepository.java:1478)
> at
> org.apache.openjpa.meta.MetaDataRepository.getPersistentTypeNames(MetaDataRepository.java:1470)
> at
> org.apache.openjpa.meta.MetaDataRepository.loadPersistentTypesInternal(MetaDataRepository.java:1522)
> at
> org.apache.openjpa.meta.MetaDataRepository.loadPersistentTypes(MetaDataRepository.java:1513)
> at
> org.apache.openjpa.meta.MetaDataRepository.loadPersistentTypes(MetaDataRepository.java:1493)
> at
> org.apache.openjpa.persistence.meta.MetamodelImpl.<init>(MetamodelImpl.java:84)
> at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.getMetamodel(EntityManagerFactoryImpl.java:345)
> at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.getMetamodel(EntityManagerFactoryImpl.java:59)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:601)
> at
> org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.invokeProxyMethod(AbstractEntityManagerFactoryBean.java:376)
> at
> org.springframework.orm.jpa.AbstractEntityManagerFactoryBean$ManagedEntityManagerFactoryInvocationHandler.invoke(AbstractEntityManagerFactoryBean.java:517)
> at $Proxy33.getMetamodel(Unknown Source)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:601)
> at
> org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:176)
> at $Proxy34.getMetamodel(Unknown Source)
> at
> org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.setEntityManager(JpaRepositoryFactoryBean.java:50)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:601)
> at
> org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:164)
> at
> org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:92)
> at
> org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:340)
> ... 15 more
> Caused by: java.io.IOException: Resource does not exist: bundle://143.10:1
> at
> org.apache.felix.framework.URLHandlersBundleURLConnection.<init>(URLHandlersBundleURLConnection.java:60)
> at
> org.apache.felix.framework.URLHandlersBundleStreamHandler.openConnection(URLHandlersBundleStreamHandler.java:64)
> at java.net.URL.openConnection(URL.java:969)
> at java.net.URL.openStream(URL.java:1035)
> at
> org.apache.openjpa.lib.util.J2DoPrivHelper$43.run(J2DoPrivHelper.java:946)
> at
> org.apache.openjpa.lib.util.J2DoPrivHelper$43.run(J2DoPrivHelper.java:944)
> at java.security.AccessController.doPrivileged(Native Method)
> at
> org.apache.openjpa.meta.AbstractCFMetaDataFactory.parsePersistentTypeNames(AbstractCFMetaDataFactory.java:769)
> at
> org.apache.openjpa.meta.AbstractCFMetaDataFactory.getPersistentTypeNames(AbstractCFMetaDataFactory.java:623)
> ... 44 more
>
> I don’t understand it, but it sounds like this is the part where OpenJPA
> is loading entity definitions?
>
> I’m surprised as Spring-Data should have handled this with some class-path
> scanning:
>
> @Bean
>     public LocalContainerEntityManagerFactoryBean
> entityManagerFactory(DataSource dataSource) throws ClassNotFoundException
> {
>         LocalContainerEntityManagerFactoryBean entityManagerFactory = newLocalContainerEntityManagerFactoryBean();
>
>         entityManagerFactory.setDataSource(dataSource);
>         entityManagerFactory.setPackagesToScan(
> "persistence.repository.jpa.entity");
>
> entityManagerFactory.setPersistenceProviderClass(PersistenceProviderImpl.
> class);
>         entityManagerFactory.setPersistenceUnitName("redbox");
>
>
>         {
>         OpenJpaVendorAdapter vendorAdaptor = new OpenJpaVendorAdapter();
>         vendorAdaptor.setDatabase(Database.POSTGRESQL);
>         vendorAdaptor.setGenerateDdl(true);
>
>
>         entityManagerFactory.setJpaVendorAdapter(vendorAdaptor);
>         }
>
>         return entityManagerFactory;
>     }
>
>
> I suspect this might be more of a Spring or OpenJPA question, but I thank
> you for any assistance you could offer.
>
> Best, Dan.
>
>
> On 27 Jan 2014, at 18:11, Achim Nierbeck <bc...@googlemail.com> wrote:
>
> Hi,
>
> I strongly suggest using Features, in favor of copying your dependencies
> to the deploy directory.
> Second, if you install the desired spring feature before the spring-dm
> one, you won't run into your
> scenario where you end up with the wrong spring-version.
>
> I don't think it's really necessary to switch to OpenJPA (though it might
> help ;))
>
> If you need more help just cry-out :)
>
> Regards, Achim
>
>
> 2014/1/27 Daniel McGreal <da...@redbite.com>
>
>> Hi,
>>
>> I’m investigating moving from Virgo to Karaf. My application uses Spring
>> Data, initially with JPA using EclipseLink.
>>
>> My strategy so far has resulted in:
>> Caused by: java.lang.IllegalArgumentException: class
>> org.eclipse.persistence.jpa.osgi.PersistenceProvider is not assignable to
>> interface javax.persistence.spi.PersistenceProvider
>>  at org.springframework.util.Assert.isAssignable(Assert.java:368)
>> at org.springframework.util.Assert.isAssignable(Assert.java:351)
>>  at
>> org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.setPersistenceProviderClass(AbstractEntityManagerFactoryBean.java:128)
>> at
>> com.redbite.redbox.persistence.repository.jpa.configuration.JpaPersistenceConfiguration.entityManagerFactory(JpaPersistenceConfiguration.java:42)
>>  at
>> com.redbite.redbox.persistence.repository.jpa.configuration.JpaPersistenceConfiguration$$EnhancerByCGLIB$$3c404459.CGLIB$entityManagerFactory$1(<generated>)
>>  at
>> com.redbite.redbox.persistence.repository.jpa.configuration.JpaPersistenceConfiguration$$EnhancerByCGLIB$$3c404459$$FastClassByCGLIB$$b6dd4002.invoke(<generated>)
>>  at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
>> at
>> org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:285)
>>  at
>> com.redbite.redbox.persistence.repository.jpa.configuration.JpaPersistenceConfiguration$$EnhancerByCGLIB$$3c404459.entityManagerFactory(<generated>)
>>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>  at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:601)
>>  at
>> org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:160)
>> ... 17 more
>>
>> It looks like the class of the spi interface is not the same class that
>> the EclipseLink class has extended, possibly due to multiple versions of
>> bundles?
>>
>> I wonder if my strategy can be improved:
>>
>>
>>    1. I use Maven copy-dependencies to populate Karaf's deploy
>>    directory, this includes Spring 3.1.4.RELEASE bundles (I haven’t installed
>>    them using features) and EclipseLink, Spring Data (& JPA) and their
>>    dependencies, e.g. CGLib & AopAlliance bundles.
>>    2. I install spring-dm manually (if I installed it using Karaf’s
>>    features it starts loading things from a Spring 3.*2*.4.RELEASE
>>    context somehow), e.g. installing each featured bundle and setting its
>>    start-level to 30 manually.
>>    3. I deploy my spring bundle which configures a DataSource
>>    and LocalContainerEntityManagerFactoryBean as beans using JavaConfig.
>>
>>
>> I don’t think I’m doing this the “Karaf Way” and wonder how it can be
>> improved? I’m not tied to EclipseLink, and could happily use e.g. OpenJPA.
>>
>> Thanks for any help you can offer,
>> Dan.
>>
>
>
>
> --
>
> Apache Karaf <http://karaf.apache.org/> Committer & PMC
> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
> Project Lead
> OPS4J Pax for Vaadin <http://team.ops4j.org/wiki/display/PAXVAADIN/Home>
> Commiter & Project Lead
> blog <http://notizblog.nierbeck.de/>
>
>
>


-- 

Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
OPS4J Pax for Vaadin <http://team.ops4j.org/wiki/display/PAXVAADIN/Home>
Commiter & Project Lead
blog <http://notizblog.nierbeck.de/>

Re: Spring Data JPA

Posted by Daniel McGreal <da...@redbite.com>.
Hi again,

I started using Karaf features for the Spring dependencies and OpenJPA.

I now have an OpenJPA error:
Exception in thread "SpringOsgiExtenderThread-2" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemRepository': Injection of persistence dependencies failed; nested exception is <openjpa-2.3.0-r422266:1540826 nonfatal general error> org.apache.openjpa.util.GeneralException: Resource does not exist: bundle://143.10:1
	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:343)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
	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:589)
	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:722)
Caused by: <openjpa-2.3.0-r422266:1540826 nonfatal general error> org.apache.openjpa.util.GeneralException: Resource does not exist: bundle://143.10:1
	at org.apache.openjpa.meta.AbstractCFMetaDataFactory.getPersistentTypeNames(AbstractCFMetaDataFactory.java:635)
	at org.apache.openjpa.meta.MetaDataRepository.getPersistentTypeNamesInternal(MetaDataRepository.java:1478)
	at org.apache.openjpa.meta.MetaDataRepository.getPersistentTypeNames(MetaDataRepository.java:1470)
	at org.apache.openjpa.meta.MetaDataRepository.loadPersistentTypesInternal(MetaDataRepository.java:1522)
	at org.apache.openjpa.meta.MetaDataRepository.loadPersistentTypes(MetaDataRepository.java:1513)
	at org.apache.openjpa.meta.MetaDataRepository.loadPersistentTypes(MetaDataRepository.java:1493)
	at org.apache.openjpa.persistence.meta.MetamodelImpl.<init>(MetamodelImpl.java:84)
	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.getMetamodel(EntityManagerFactoryImpl.java:345)
	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.getMetamodel(EntityManagerFactoryImpl.java:59)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.invokeProxyMethod(AbstractEntityManagerFactoryBean.java:376)
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean$ManagedEntityManagerFactoryInvocationHandler.invoke(AbstractEntityManagerFactoryBean.java:517)
	at $Proxy33.getMetamodel(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:176)
	at $Proxy34.getMetamodel(Unknown Source)
	at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.setEntityManager(JpaRepositoryFactoryBean.java:50)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:164)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:92)
	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:340)
	... 15 more
Caused by: java.io.IOException: Resource does not exist: bundle://143.10:1
	at org.apache.felix.framework.URLHandlersBundleURLConnection.<init>(URLHandlersBundleURLConnection.java:60)
	at org.apache.felix.framework.URLHandlersBundleStreamHandler.openConnection(URLHandlersBundleStreamHandler.java:64)
	at java.net.URL.openConnection(URL.java:969)
	at java.net.URL.openStream(URL.java:1035)
	at org.apache.openjpa.lib.util.J2DoPrivHelper$43.run(J2DoPrivHelper.java:946)
	at org.apache.openjpa.lib.util.J2DoPrivHelper$43.run(J2DoPrivHelper.java:944)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.apache.openjpa.meta.AbstractCFMetaDataFactory.parsePersistentTypeNames(AbstractCFMetaDataFactory.java:769)
	at org.apache.openjpa.meta.AbstractCFMetaDataFactory.getPersistentTypeNames(AbstractCFMetaDataFactory.java:623)
	... 44 more

I don’t understand it, but it sounds like this is the part where OpenJPA is loading entity definitions?

I’m surprised as Spring-Data should have handled this with some class-path scanning:

	@Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) throws ClassNotFoundException {
        LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();

        entityManagerFactory.setDataSource(dataSource);
        entityManagerFactory.setPackagesToScan("persistence.repository.jpa.entity");
        entityManagerFactory.setPersistenceProviderClass(PersistenceProviderImpl.class);
        entityManagerFactory.setPersistenceUnitName("redbox");
        
        {
        	OpenJpaVendorAdapter vendorAdaptor = new OpenJpaVendorAdapter();
        	vendorAdaptor.setDatabase(Database.POSTGRESQL);
        	vendorAdaptor.setGenerateDdl(true);
        	
        	entityManagerFactory.setJpaVendorAdapter(vendorAdaptor);
        }

        return entityManagerFactory;
    }


I suspect this might be more of a Spring or OpenJPA question, but I thank you for any assistance you could offer.

Best, Dan.


On 27 Jan 2014, at 18:11, Achim Nierbeck <bc...@googlemail.com> wrote:

> Hi, 
> 
> I strongly suggest using Features, in favor of copying your dependencies to the deploy directory. 
> Second, if you install the desired spring feature before the spring-dm one, you won't run into your
> scenario where you end up with the wrong spring-version. 
> 
> I don't think it's really necessary to switch to OpenJPA (though it might help ;)) 
> 
> If you need more help just cry-out :)
> 
> Regards, Achim 
> 
> 
> 2014/1/27 Daniel McGreal <da...@redbite.com>
> Hi,
> 
> I’m investigating moving from Virgo to Karaf. My application uses Spring Data, initially with JPA using EclipseLink.
> 
> My strategy so far has resulted in:
> Caused by: java.lang.IllegalArgumentException: class org.eclipse.persistence.jpa.osgi.PersistenceProvider is not assignable to interface javax.persistence.spi.PersistenceProvider
> 	at org.springframework.util.Assert.isAssignable(Assert.java:368)
> 	at org.springframework.util.Assert.isAssignable(Assert.java:351)
> 	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.setPersistenceProviderClass(AbstractEntityManagerFactoryBean.java:128)
> 	at com.redbite.redbox.persistence.repository.jpa.configuration.JpaPersistenceConfiguration.entityManagerFactory(JpaPersistenceConfiguration.java:42)
> 	at com.redbite.redbox.persistence.repository.jpa.configuration.JpaPersistenceConfiguration$$EnhancerByCGLIB$$3c404459.CGLIB$entityManagerFactory$1(<generated>)
> 	at com.redbite.redbox.persistence.repository.jpa.configuration.JpaPersistenceConfiguration$$EnhancerByCGLIB$$3c404459$$FastClassByCGLIB$$b6dd4002.invoke(<generated>)
> 	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
> 	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:285)
> 	at com.redbite.redbox.persistence.repository.jpa.configuration.JpaPersistenceConfiguration$$EnhancerByCGLIB$$3c404459.entityManagerFactory(<generated>)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:601)
> 	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:160)
> 	... 17 more
> 
> It looks like the class of the spi interface is not the same class that the EclipseLink class has extended, possibly due to multiple versions of bundles?
> 
> I wonder if my strategy can be improved:
> 
> I use Maven copy-dependencies to populate Karaf's deploy directory, this includes Spring 3.1.4.RELEASE bundles (I haven’t installed them using features) and EclipseLink, Spring Data (& JPA) and their dependencies, e.g. CGLib & AopAlliance bundles.
> I install spring-dm manually (if I installed it using Karaf’s features it starts loading things from a Spring 3.2.4.RELEASE context somehow), e.g. installing each featured bundle and setting its start-level to 30 manually.
> I deploy my spring bundle which configures a DataSource and LocalContainerEntityManagerFactoryBean as beans using JavaConfig.
> 
> I don’t think I’m doing this the “Karaf Way” and wonder how it can be improved? I’m not tied to EclipseLink, and could happily use e.g. OpenJPA.
> 
> Thanks for any help you can offer, 
> Dan.
> 
> 
> 
> -- 
> 
> Apache Karaf <http://karaf.apache.org/> Committer & PMC
> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
> OPS4J Pax for Vaadin <http://team.ops4j.org/wiki/display/PAXVAADIN/Home> Commiter & Project Lead
> blog <http://notizblog.nierbeck.de/>


Re: Spring Data JPA

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi,

I strongly suggest using Features, in favor of copying your dependencies to
the deploy directory.
Second, if you install the desired spring feature before the spring-dm one,
you won't run into your
scenario where you end up with the wrong spring-version.

I don't think it's really necessary to switch to OpenJPA (though it might
help ;))

If you need more help just cry-out :)

Regards, Achim


2014/1/27 Daniel McGreal <da...@redbite.com>

> Hi,
>
> I’m investigating moving from Virgo to Karaf. My application uses Spring
> Data, initially with JPA using EclipseLink.
>
> My strategy so far has resulted in:
> Caused by: java.lang.IllegalArgumentException: class
> org.eclipse.persistence.jpa.osgi.PersistenceProvider is not assignable to
> interface javax.persistence.spi.PersistenceProvider
> at org.springframework.util.Assert.isAssignable(Assert.java:368)
> at org.springframework.util.Assert.isAssignable(Assert.java:351)
> at
> org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.setPersistenceProviderClass(AbstractEntityManagerFactoryBean.java:128)
> at
> com.redbite.redbox.persistence.repository.jpa.configuration.JpaPersistenceConfiguration.entityManagerFactory(JpaPersistenceConfiguration.java:42)
> at
> com.redbite.redbox.persistence.repository.jpa.configuration.JpaPersistenceConfiguration$$EnhancerByCGLIB$$3c404459.CGLIB$entityManagerFactory$1(<generated>)
> at
> com.redbite.redbox.persistence.repository.jpa.configuration.JpaPersistenceConfiguration$$EnhancerByCGLIB$$3c404459$$FastClassByCGLIB$$b6dd4002.invoke(<generated>)
> at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
> at
> org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:285)
> at
> com.redbite.redbox.persistence.repository.jpa.configuration.JpaPersistenceConfiguration$$EnhancerByCGLIB$$3c404459.entityManagerFactory(<generated>)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:601)
> at
> org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:160)
> ... 17 more
>
> It looks like the class of the spi interface is not the same class that
> the EclipseLink class has extended, possibly due to multiple versions of
> bundles?
>
> I wonder if my strategy can be improved:
>
>
>    1. I use Maven copy-dependencies to populate Karaf's deploy directory,
>    this includes Spring 3.1.4.RELEASE bundles (I haven’t installed them using
>    features) and EclipseLink, Spring Data (& JPA) and their dependencies, e.g.
>    CGLib & AopAlliance bundles.
>    2. I install spring-dm manually (if I installed it using Karaf’s
>    features it starts loading things from a Spring 3.*2*.4.RELEASE
>    context somehow), e.g. installing each featured bundle and setting its
>    start-level to 30 manually.
>    3. I deploy my spring bundle which configures a DataSource
>    and LocalContainerEntityManagerFactoryBean as beans using JavaConfig.
>
>
> I don’t think I’m doing this the “Karaf Way” and wonder how it can be
> improved? I’m not tied to EclipseLink, and could happily use e.g. OpenJPA.
>
> Thanks for any help you can offer,
> Dan.
>



-- 

Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
OPS4J Pax for Vaadin <http://team.ops4j.org/wiki/display/PAXVAADIN/Home>
Commiter & Project Lead
blog <http://notizblog.nierbeck.de/>

Re: Spring Data JPA

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Thanks,

I gonna take a look on that.

Regards
JB

On 01/29/2014 01:16 AM, nseb wrote:
> I have a bundle name repository , in this bundle I have the classes attached
> in my reply.
> The bundle has instruction dynamic-import
>
> AbstractJeetJpaRepositoryBase.java
> <http://karaf.922171.n3.nabble.com/file/n4031383/AbstractJeetJpaRepositoryBase.java>
> JeetJpaRepositoryFactoryBean.java
> <http://karaf.922171.n3.nabble.com/file/n4031383/JeetJpaRepositoryFactoryBean.java>
> JeetJpaRepositoryImpl.java
> <http://karaf.922171.n3.nabble.com/file/n4031383/JeetJpaRepositoryImpl.java>
> JeetRepository.java
> <http://karaf.922171.n3.nabble.com/file/n4031383/JeetRepository.java>
>
> After , for use in your blueprint.xml with your repository , in my exampl :
> com.jeet.domain.party.service.impl.role.repository.RoleRepository is the
> interface
>
> <bean id="roleRepositoryFactory"
>
> class="com.jeet.domain.base.service.repository.jpa.JeetJpaRepositoryFactoryBean"
>            init-method="afterPropertiesSet">
>          <jpa:context property="entityManager" unitname="jeet-core-pu"/>
>          <property name="repositoryInterface"
>
> value="com.jeet.domain.party.service.impl.role.repository.RoleRepository"/>
>
>      </bean>
>
>      <bean id="roleRepository" factory-ref="roleRepositoryFactory"
>            factory-method="getObject">
>          <tx:transaction method="*" value="Required"/>
>      </bean>
>
>
>
>
>
> -----
> CTO , JeetConsulting.
>
> Analyze now your Maven Java projects' dependencies , here
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Spring-Data-JPA-tp4031348p4031383.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Spring Data JPA

Posted by nseb <se...@hotmail.com>.
I have a bundle name repository , in this bundle I have the classes attached
in my reply. 
The bundle has instruction dynamic-import

AbstractJeetJpaRepositoryBase.java
<http://karaf.922171.n3.nabble.com/file/n4031383/AbstractJeetJpaRepositoryBase.java>  
JeetJpaRepositoryFactoryBean.java
<http://karaf.922171.n3.nabble.com/file/n4031383/JeetJpaRepositoryFactoryBean.java>  
JeetJpaRepositoryImpl.java
<http://karaf.922171.n3.nabble.com/file/n4031383/JeetJpaRepositoryImpl.java>  
JeetRepository.java
<http://karaf.922171.n3.nabble.com/file/n4031383/JeetRepository.java>  

After , for use in your blueprint.xml with your repository , in my exampl :
com.jeet.domain.party.service.impl.role.repository.RoleRepository is the
interface 

<bean id="roleRepositoryFactory"
         
class="com.jeet.domain.base.service.repository.jpa.JeetJpaRepositoryFactoryBean"
          init-method="afterPropertiesSet">
        <jpa:context property="entityManager" unitname="jeet-core-pu"/>
        <property name="repositoryInterface"
                 
value="com.jeet.domain.party.service.impl.role.repository.RoleRepository"/>

    </bean>

    <bean id="roleRepository" factory-ref="roleRepositoryFactory"
          factory-method="getObject">
        <tx:transaction method="*" value="Required"/>
    </bean>





-----
CTO , JeetConsulting.

Analyze now your Maven Java projects' dependencies , here 
--
View this message in context: http://karaf.922171.n3.nabble.com/Spring-Data-JPA-tp4031348p4031383.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Spring Data JPA

Posted by nseb <se...@hotmail.com>.
We use spring-data in karaf , I go to prepare a sample for tonight.



-----
CTO , JeetConsulting.

Analyze now your Maven Java projects' dependencies , here 
--
View this message in context: http://karaf.922171.n3.nabble.com/Spring-Data-JPA-tp4031348p4031379.html
Sent from the Karaf - User mailing list archive at Nabble.com.