I have a project I'm building using struts2 and openJPA. I want to do some integration testing but I seem to be having an issue getting it to work.
persistence.xml
<persistence-unit name="SalesCertIT" transaction-type="RESOURCE_LOCAL">
<jta-data-source>jdbc/salesCertIT</jta-data-source>
<class>com.ist.salesCert.entities.Certification</class>
<properties>
<property name="log4j" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE" />
<property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver" />
<property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost:3306/sales_certification" />
<property name="openjpa.ConnectionUserName" value="dev" />
<property name="openjpa.ConnectionPassword" value="password" />
<property name="openjpa.Id" value="SalesCertIT" />
<property name="openjpa.ConnectionDriverName" value="org.apache.derby.jdbc.EmbeddedDriver" />
</properties>
</persistence-unit>
class:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("SalesCertIT");
EntityManager em = emf.createEntityManager();
I get the error:
A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.
I've added both the persistence.xml and mysql-connector-java-*-stable-bin-jar to the classpath, (Eclipse->debug Configuration->Classpath->Bootstrap entries)
If I try to configure it at runtime it does work but then I get another error when trying to perform an operation:
HashMap<String, String> conf = new HashMap<String, String>();
conf.put("openjpa.ConnectionDriverName", "com.mysql.jdbc.Driver");
conf.put("openjpa.ConnectionURL", "jdbc:mysql://localhost:3306/sales_certification");
conf.put("openjpa.ConnectionUserName", "dev");
conf.put("openjpa.ConnectionPassword", "password");
conf.put("openjpa.TransactionMode", "local");
conf.put("openjpa.Id", "SalesCertIT");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("SalesCertIT", conf);
EntityManager em = emf.createEntityManager();
The type "class com.ist.salesCert.entities.Certification" has not been enhanced.
I tried to add a javaagent argument: (Eclipse->Debug Configurations->Arguments->VM arguments)
-javaagent:C:/Progra~1/IBM/WebSphere/AppServer/plugins/com.ibm.ws.jpa.jar
At this point I don't know what else to try. Any ideas?