0

I'm coding an app that uses Servlet 3.0, Jsp, and JPA 2.0 and i'm deploying it into Websphere application server 8.5. Since i already configured into the ibm websphere console, the data source and the jdbc driver, and the j2c authentification (i'm using oracle 11g as a database ). I dont know how my persistence.xml should look like, if i need to specify and add openJPA jars to my project. For now anything i put into persistence.xml i'm having this issue :

Error 500: <openjpa-2.2.3-SNAPSHOT-r422266:1764177 fatal user error> org.apache.openjpa.persistence.ArgumentException

What should i do ? maybe i'm missing how JPA works

Thanks in advance

1 Answers1

0

The OpenJPA jars should be provided by WebSphere and available to use for your application. There is a JPA sample available here: https://developer.ibm.com/wasdev/downloads/#asset/samples-Java_Persistence_API_JPA_Sample

In the sample, you can see an example of the persistence.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">

  <persistence-unit name="jpasamplepersistenceunit">

    <jta-data-source>java:comp/env/jdbc/samplejpadatasource</jta-data-source>
    <non-jta-data-source>java:comp/env/jdbc/samplejpadatasourcenonjta</non-jta-data-source>

    <class>wasdev.sample.jpa.Thing</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
      <!-- These properties are creating the database on the fly. We are using them to avoid users having
          to create a database to run the sample. 
          See also the create=true line in the datasource meta data. -->
      <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" />
      <property name="openjpa.jdbc.DBDictionary" value="derby" />

      <!-- EclipseLink specific properties to create the database. They are only used if using the jpa-2.1 feature. -->
        <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
        <property name="eclipselink.ddl-generation.output-mode" value="both" />

    </properties>
  </persistence-unit>

</persistence>

I think your error is not caused by the OpenJPA jars not being available. It might be because your database is not configured correctly. Make sure your persistence.xml file refers to your datasources properly.

dalia
  • 146
  • 4