I use Java 8 and Felix 5.4.0. This is the bundle list I install and start BEFORE starting my main bundle.
<bundle name="javax.persistence-2.1.1.jar"/>
<bundle name="org.eclipse.persistence.asm-2.6.3-M1.jar"/>
<bundle name="org.eclipse.persistence.antlr-2.6.3-M1.jar"/>
<bundle name="org.eclipse.persistence.core-2.6.3-M1.jar"/>
<bundle name="org.eclipse.persistence.jpa-2.6.3-M1.jar"/>
<bundle name="org.eclipse.persistence.jpa.jpql-2.6.3-M1.jar"/>
<bundle name="org.eclipse.gemini.jpa_1.2.0.M1.jar"/>
<bundle name="org.eclipse.gemini.dbaccess.h2-1.1.0.RELEASE.jar"/>
<bundle name="org.eclipse.gemini.dbaccess.util_1.1.0.201206011559.jar"/>
To manifest of bundle with persistence.xml I added:
Meta-Persistence: META-INF/persistence.xml (Although I am not sure it is necessary)
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="htt p://java.sun.com/xml/ns/persistence"
xmlns:xsi="htt p://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="htt p://java.sun.com/xml/ns/persistence htt p://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="myPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.temp.PersonItem</class>
<properties>
<!-- Configuring JDBC properties -->
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:h2:tcp://localhost//home/data/database"/>
<property name="javax.persistence.jdbc.user" value="sa"/>
<property name="javax.persistence.jdbc.password" value=""/>
<property name="eclipselink.logging.level" value="FINE"/>
<property name="eclipselink.logging.timestamp" value="false"/>
<property name="eclipselink.logging.thread" value="false"/>
<property name="eclipselink.logging.exceptions" value="true"/>
<property name="eclipselink.orm.throw.exceptions" value="true"/>
<property name="eclipselink.jdbc.read-connections.min" value="1"/>
<property name="eclipselink.jdbc.write-connections.min" value="1"/>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.weaving" value="true"/>
</properties>
</persistence-unit>
</persistence>
This is the code how I try to get gemini service
BundleContext context = thisBundle.getBundleContext();
ServiceReference serviceReference = context.getServiceReference( EntityManagerFactory.class.getName() );
if (serviceReference==null){
System.out.println("@@@:1"); // I COME HERE
}else{
System.out.println("@@@:2");
}
emf= (EntityManagerFactory) context.getService( serviceReference );
String unitName = (String)serviceReference.getProperty(EntityManagerFactoryBuilder.JPA_UNIT_NAME);
System.out.println("Name:"+unitName);
Please, help me to solve this problem. P.S. I added space in http because otherwise I couldn't post this topic.