Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make PostgreSQL work with OSGi using EclipseLink
    text
    copied!<p>I need to develop a OSGi bundle with EclipseLink, which should connect to PostgreSQL, but I wasted a bunch of time and could not make it work. I receive this "javax.persistence.PersistenceException: No Persistence provider for EntityManager named rooms".</p> <p>Basically, I followed the steps of tutorials I found on the web. I use Eclipse Indigo</p> <pre><code>Manifest file : Manifest-Version: 1.0 Meta-Persistence: persistence.xml JPA-PersistenceUnits: rooms Bundle-ClassPath: ., META-INF/persistence.xml Bundle-ManifestVersion: 2 Bundle-Name: PMSTestTask Bundle-SymbolicName: PMSTestTask Bundle-Version: 1.0.0.qualifier Bundle-Activator: pmstesttask.Activator Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: javax.persistence;version="2.0.3", org.osgi.framework;version="1.3.0", org.postgresql Require-Bundle: org.eclipse.persistence.jpa;bundle-version="2.1.0", org.eclipse.persistence.jpa.osgi;bundle-version="2.3.0" </code></pre> <p>persistence.xml</p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;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" xmlns="http://java.sun.com/xml/ns/persistence"&gt; &lt;persistence-unit name="rooms" transaction-type="RESOURCE_LOCAL"&gt; &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt; &lt;class&gt;test_task.domain.Room&lt;/class&gt; &lt;properties&gt; &lt;property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /&gt; &lt;property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/Hotel_test_task" /&gt; &lt;property name="javax.persistence.jdbc.user" value="" /&gt; &lt;property name="javax.persistence.jdbc.password" value="" /&gt; &lt;/properties&gt; &lt;/persistence-unit&gt; &lt;/persistence&gt; </code></pre> <p>Activator.java</p> <pre><code> EntityManagerFactory emf = Persistence .createEntityManagerFactory("rooms"); EntityManager em = emf.createEntityManager(); </code></pre> <p>Update. 0</p> <p>Added required-bundle to manifest. And got this </p> <pre><code>org.osgi.framework.BundleException: The bundle "org.eclipse.persistence.jpa.osgi_2.3.0.v20110604-r9504 [26]" could not be resolved. Reason: Missing Constraint: Require-Bundle: org.eclipse.persistence.core; bundle-version="2.3.0" </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload