Websphere 7 EAR using OpenJPA 1.0

javitor52x

New Member
We have an EAR application that contains a WAR, Utility project and a JPA project. The JPA project contains all our entity classes and in the META-INF directory is our persistence.xml which is defined as follows:\[code\] <?xml version="1.0" encoding="UTF-8"?><persistence version="1.0" 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_1_0.xsd"> <persistence-unit name="TestJPA"> <description>openjpa</description> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> <jta-data-source>jdbc/TestSource</jta-data-source> <class>model.TestTable1</class> <class>model.TestTable2</class> </persistence-unit></persistence>\[/code\]Our web.xml contains the following for the persistence unit.\[code\] <persistence-unit-ref> <persistence-unit-ref-name>peristence/TestJPA</persistence-unit-ref-name> <persistence-unit-name>TestJPA</persistence-unit-name> </persistence-unit-ref>\[/code\]In our webservice we have the following:\[code\]@PersistenceContext(name="peristence/TestJPA", unitName="TestJPA")private EntityManagerFactory emf;\[/code\]When the application is deployed emf never gets instantiated. Its always null. We've tried @PersistenceUnit as well, with and without arguments.We've also tried a different approach by using InitialContext lookup to get an EntityManager. Using this approach an exception gets thrown that it can't find the resource name.Our last approach we tried was the following:\[code\]em = (EntityManager) Persistence.createEntityManagerFactory("TestJPA");\[/code\]Which produces the following exception \[code\]java.lang.ClassCastException: com.ibm.ws.persistence.EntityManagerFactoryImpl incompatible with javax.persistence.EntityManager\[/code\]I've looked for all sorts of tutorials with regard to OpenJPA deployment with an EAR, but all of them are either for JPA 2 or for OpenJPA 1 with Spring.Any help would be appreciated.
 
Back
Top