Did you export the EclipseLink persistence provider? https://github.com/lburgazzoli/lb-karaf-examples
On Thursday, March 14, 2013, ingulp wrote: > I know there are several questions related to this, but none have been able > to solve my problem. As it stands, I believe that my persistence.xml is > simply not being registered or parsed by the container. > > I'm running as a maven application, which is built and then manually > deployed to my Karaf (2.2.10) OSGi container. > > The original web-service tutorial I followed can be found here: > > http://www.liquid-reality.de/display/liquid/2011/12/22/Karaf+Tutorial+Part+4+-+CXF+Services+in+OSGi > The tutorial does not include anything persistence-related - only setting > up > web services through CXF in Karaf. My problem is coming from trying to add > persistence support through eclipselink. > > While it may be possible to upgrade to Gemini JPA, administrative powers > greater than I would like this to be done in eclipselink. > > *Manifest.xml:* > Manifest-Version: 1.0 > Bnd-LastModified: 1363204729441 > Build-Jdk: 1.6.0_39 > Bundle-ManifestVersion: 2 > Bundle-Name: stuffservice-server > Bundle-SymbolicName: stuffservice-server > Bundle-Version: 1.1.0.SNAPSHOT > Created-By: Apache Maven Bundle Plugin > Import-Package: stuffservice.stuff;version="[1.1 > ,2)",com.google.gson;version="[2.2,3)",javax.persistence;version="[2.0, > 3)",javax.ws.rs;version="[1.1,2)",org.apache.cxf.endpoint,org.apache.cx > f.jaxrs,org.apache.cxf.jaxrs.lifecycle,org.osgi.service.blueprint;versi > on="[1.0.0,2.0.0)" > JPA-PersistenceUnits: testingtesting > Meta-Persistence: META-INF/persistence.xml > Tool: Bnd-1.50.0 > > > I can verify that persistence.xml is being copied to the same directory as > the Manifest.MF (target/classes/META-INF/) upon maven install. I believe > that's what is supposed to happen, but feel free to correct me if I'm > wrong! > *persistence.xml:* > <persistence xmlns="http://java.sun.com/xml/ns/persistence" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://java.sun.com/xml/ns/persistence > http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" > version="2.0"> > > <persistence-unit name="testingtesting" > transaction-type="RESOURCE_LOCAL"> > > <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> > <exclude-unlisted-classes>false</exclude-unlisted-classes> > <properties> > <property name="eclipselink.ddl-generation" > value="drop-and-create-tables" /> > <property name="eclipselink.jdbc.driver" > value="org.postgresql.Driver" /> > <property name="eclipselink.jdbc.url" > value="jdbc:postgresql://localhost/testdb" /> > <property name="eclipselink.jdbc.user" value="----------" /> > <property name="eclipselink.jdbc.password" value="----------" > /> > </properties> > </persistence-unit> > </persistence> > > *Directory Structure:* > src > main > java > stuffservice > impl > StuffServiceImpl.java > resources > META-INF > persistence.xml > OSGI-INF > ... > > *StuffServiceImpl.java:* > Within the constructor, I originally had no properties map, etc - just emf > = > Persistence.createEntityManagerFactory("testingtesting", properties); I was > pointed in the properties direction from various other questions posted > here > on SO, to no avail. I'm assuming this may be unusable outside of an > Activator class? > ... > public class StuffServiceImpl implements StuffService { > @PersistenceUnit > EntityManagerFactory emf; > Map<String, Stuff> stuffMap; > > public StuffServiceImpl() { > Map<String,Object> properties = new HashMap<String, Object>(); > properties.put(PersistenceUnitProperties.CLASSLOADER, > this.getClass().getClassLoader()); > emf = Persistence.createEntityManagerFactory("testingtesting", > properties); > stuffMap = new HashMap<String, Stuff>(); > Stuff stuff = createExampleStuff(); > stuffMap.put("1", stuff); > } > > *Error:* > 2013-03-13 14:52:56,699 | ERROR | rint Extender: 3 | > BlueprintContainerImpl | 9 - org.apache.aries.blueprint - 0.3.2 | > Unable to start blueprint container for bundle stuffservice-server > org.osgi.service.blueprint.container.ComponentDefinitionException: > Error > when instanciating bean stuffServiceImpl of class class > stuffservice.impl.stuffServiceImpl > at > > org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:271)[9:org.apache.aries.blueprint:0.3.2] > at > > org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:708)[9:org.apache.aries.blueprint:0.3.2] > at > > org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:64)[9:org.apache.aries.blueprint:0.3.2] > at > > org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:219)[9:org.apache.aries.blueprint:0.3.2] > at > > org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:147)[9:org.apache.aries.blueprint:0.3.2] > at > > org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:631)[9:org.apache.aries.blueprint:0.3.2] > at > > org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:337)[9:org.apache.aries.blueprint:0.3.2] > at > > org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:230)[9:org.apache.aries.blueprint:0.3.2] > at > > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)[:1.6.0_39] > at > > java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)[:1.6.0_39] > at > java.util.concurrent.FutureTask.run(FutureTask.java:138)[:1.6.0_39] > at > > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)[:1.6.0_39] > at > > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)[:1.6.0_39] > at > > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)[:1.6.0_39] > at > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)[:1.6.0_39] > at java.lang.Thread.run(Thread.java:662)[:1.6.0_39] > Caused by: javax.persistence.PersistenceException: *No Persistence > provider for EntityManager named testingtesting* > at > > javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:84) > at > stuffservice.impl.stuffServiceImpl.<init>(stuffServiceImpl.java:51) > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native > Method)[:1.6.0_39] > at > > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)[:1.6.0_39] > at > > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)[:1.6.0_39] > at > java.lang.reflect.Constructor.newInstance(Constructor.java:513)[:1.6.0_39] > at > > org.apache.aries.blueprint.utils.ReflectionUtils.newInstance(ReflectionUtils.java:257)[9:org.apache.aries.blueprint:0.3.2] > at > > org.apache.aries.blueprint.container.BeanRecipe.newInstance(BeanRecipe.java:842)[9:org.apache.aries.blueprint:0.3.2] > at > > org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:269)[9:org.apache.aries.blueprint:0.3.2] > ... 15 more > > > > I've been trying to deal with this issue for a few days, now, with no luck. > Something that just hit me earlier this morning - would setting up another, > eclipselink-specific osgi package and then accessing it from the web > service > be a better solution? Forgive me if this sounds like a novice OSGi > question, as I am a novice in OSGi :) > > > > -- > View this message in context: > http://karaf.922171.n3.nabble.com/Karaf-OSGi-Web-Service-with-EclipseLink-No-Persistence-provider-tp4028199.html > Sent from the Karaf - User mailing list archive at Nabble.com. >
