I have read a few issues by people not being able to get EclipseLink running within an RCP application. I haven't been able to solve this issue yet.
When the code below is run in a test suite persistence work fine. However an error is thrown on line 2 when I run this from an e4 RCP application:
EntityManagerFactoryHelper emFactoryHelper = new EntityManagerFactoryHelper();
em = emFactoryHelper.getFactory().createEntityManager();
Error:
javax.persistence.PersistenceException: Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Unable to acquire a connection from driver [net.sf.log4jdbc.DriverSpy], user [sa] and URL [jdbc:hsqldb:hsql://localhost/test]. Verify that you have set the expected driver class and URL. Check your login, persistence.xml or sessions.xml resource. The jdbc.driver property should be set to a class that is compatible with your database platform
Internal Exception: java.sql.SQLException: No suitable driver found for jdbc:hsqldb:hsql://localhost/test
persistence.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<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">
<persistence-unit name="parameters" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.test.jpa.Model</class>
</persistence-unit>
</persistence>
Manifest in persistence plugin:
... Eclipse-RegisterBuddy: com.test.mainapp ..
Manifest in main application:
... Eclipse-BuddyPolicy: registered ...
I also added the following to mainifest in the main app, though I think it is only relevent for OSGI bundles rather than plugins:
JPA-PersistenceUnits: com.test.jpa
NB I am using plugins rather than OSGI bundles, and com.test.jpa is the persistence plugin.