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.