Introduction to JPA – Part 1 – Getting Started

September 4th, 2008  | Tags: , , , ,

The Java Persistence API or simply JPA is the standard object/relational mapping and persistence management interface of the Java EE 5.0 platform. As part of the EJB 3.0 specification effort, it is supported by all major vendors of the Java industry.

JPA runs on the Persistence Layer (see figure below) and create a separation between our application and the underlying database.

Using JPA, you aren’t going to deal with SQL statements directly, instead, you are going to deal with the Objects itself. No more huge INSERTS, UPDATES, DELETES. Simply use EntityManager.persist(), EntityManager.remove(), EntityManager.merge() and so on.

The tables from database are represented by objects in the application. The insert, update, deletes statements are transparent for the developers, the JPA takes care of these operations.

As JPA is an specification, there are some vendors who implement that specification. We can highlight the following:

In theory, the behavior among them are the same. Hence if you change the provider, the application should work in the same way, but unfortunately it isn’t true. So be careful when you’re going to choose the implementation.

In this introduction, we’re going to talk about these 3 implementations. We’re going to use the same example, however using the different implementations. We’re going to show up which .JARs files are required, as well as the required configuration (persistence.xml).

Preparing the environment

First of all, we need to setup our environment. For this post, I am going to use the MySQL database and Eclipse IDE. You’re free to use another database or IDE, but make sure to setup the config files properly.

The first step is to create the database. In the MySQL, let’s create a database name called jpa_introduction. Type the following into MySQL Console.

mysql> create database jpa_introduction;
Query OK, 1 row affected (0.03 sec)
mysql>

Now, let’s create our database. For our example, we’re going to use only one table called People with 4 fields: Id, Name, Address, City. The SQL statement looks like:

create table people (
id integer not null auto_increment,
name varchar(40),
address varchar(60),
city varchar(40),
primary key(id)
);

Now let’s prepare the Eclipse Environment. Open it and go to the Java Perspective.

Go to File -> New -> Java Project. Insert the Project Name: JPA_Hibernate and click on Finish button. The JPA_Hibernate project will be created.

Also, create a folder called META-INF into the src folder of the project. Right click on src and go to New -> Folder. Choose the name META-INF and click on Finish.

Repeat the same process but now creating a folder called lib in the root of the project.

Finally, let’s create a empty file called persistence.xml within META-INF directory. Right click on META-INF folder, New -> File. Choose the name persistence.xml. Keep the content of this file empty for time being. The basic structure of your project should look like below:

The basic is done. Now you must choose which implementation you’re going to use. For all implementation, the application code will be the same, the difference among them is the JARs file you must insert in the CLASSPATH, as well as the content of persistence.xml file.

Below following the required information for all implementations. After you pick up one, you can skip the information from others implementations.

Using Hibernate implementation

Let’s get started with the most famous implementation: Hibernate. By the way, Hibernate came first than JPA and many people say that JPA was based on Hibernate implementation.

Go to the Hibernate Official Site and download the following:

Choosing the JAR files

For hibernate implementation, you must copy the following JARs file to the application/lib directory:

  • hibernate3.jar from hibernate-distribution-3.3.0.SP1 folder.
  • all jar files from hibernate-distribution-3.3.0.SP1/lib/required folder.
  • hibernate-annotations.jar from hibernate-annotations-3.4.0.GA folder.
  • ejb3-persistence.jar, dom4j.jar, hibernate-commons-annotations.jar from hibernate-annotations-3.4.0.GA/lib folder.
  • slf4j-log4j12.jar from hibernate-annotations-3.4.0.GA/lib/test folder.
  • hibernate-entitymanager.jar from hibernate-entitymanager-3.4.0.GA folder.

Also, you must copy the .jar file from the JDBC driver. In my case (MySQL), I copied the mysql-connector-java-5.1.6-bin.jar file to JPA_Introduction/lib directory.

Setup the persistence.xml file

For hibernate implementation, you should use the following content into META-INF/persistence.xml file:

<persistence 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"
	version="1.0">
	<persistence-unit name="jpa_introduction" transaction-type="RESOURCE_LOCAL">
		<provider>org.hibernate.ejb.HibernatePersistence</provider>
		<properties>
			<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
			<property name="hibernate.connection.username" value="xxx" />
			<property name="hibernate.connection.password" value="xxx" />
			<property name="hibernate.connection.url" value="jdbc:mysql://localhost/jpa_introduction" />
			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
		</properties>
	</persistence-unit>
</persistence>

Note: If you’re using another database, change the hibernate.dialect, connection.driver_class and connection.url. All the information you can see here.

Using Oracle Toplink implementation

The first think to do is to download the JARs files.

From the official site, download them. Copy both files to the lib directory:

  • toplink-essentials.jar
  • toplink-essentials-agent.jar

Also, add the JDBC driver in the lib directory.

Setup the persistence.xml file

For Toplink, use the following persistence.xml content:

<persistence 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 persistence_1_0.xsd"
	version="1.0">
	<persistence-unit name="jpa_introduction" transaction-type="RESOURCE_LOCAL">
		<provider> oracle.toplink.essentials.PersistenceProvider </provider>
		<class>entities.Person</class>
		<properties>
			<property name="toplink.logging.level" value="FINE" />
			<property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver" />
			<property name="toplink.jdbc.url" value="jdbc:mysql://localhost/jpa_introduction" />
			<property name="toplink.jdbc.password" value="xxx" />
			<property name="toplink.jdbc.user" value="xxx" />
		</properties>
	</persistence-unit>
</persistence>

It’s done.

Using Apache OpenJPA implementation

Now let’s show up the required configuration for Apache OpenJPA. By the way, this is the default implementation used by IBM Websphere Application Server.

Like the other example, we’re going to use exactly the same Java code. Only the JARs files and the persistence.xml content will be changed.

Download the required JAR file directly from the download page. After that, extract it and copy the following:

  • openjpa-1.2.0.jar from apache-openjpa-1.2.0 folder.
  • ALL JAR files from apache-openjpa-1.2.0/lib.
  • The JDBC driver class.

Setup the persistence.xml file

For OpenJPA, use the following persistence.xml content:

<persistence 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 persistence_1_0.xsd"
	version="1.0">
	<persistence-unit name="jpa_introduction"
		transaction-type="RESOURCE_LOCAL">
		<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
		<class>entities.Person</class>
		<properties>
			<property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost/jpa_introduction" />
			<property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver" />
			<property name="openjpa.ConnectionUserName" value="xxx" />
			<property name="openjpa.ConnectionPassword" value="xxx" />
			<property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO" />
		</properties>
	</persistence-unit>
</persistence>

It’s done. You can use Apache OpenJPA right now.

Setup the Eclipse Classpath

After you have chosen the implementation and all jars files were copied to lib directory, it is time to create the classpath into Eclipse. Fortunately it is an easy task. Go to Eclipse, rigth mouse click on JPA_Introduction project -> Properties -> Java Build Path -> Libraries -> Add JARs -> Select ALL JARs from lib directory.

Coding

Entity

Let’s get started coding the Entity. The entity is the representation of the table but in the domain layer. The entity is a POJO class. Each attribute is associated to the field from the table. So, let’s create our Entity into the entities package.

package entities;
 
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
 
@Entity
@Table(name="people")
@NamedQuery(name="getListOfPeople", query="select p from Person p")
public class Person {
 
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer id;
    private String name;
    private String address;
    private String city;
    //Getters and Setters

Some details about the entity:

  • It must be annotated with @Entity or mapped to XML
  • It must be public, top-level and cannot be final
  • The attributes cannot be public and final
  • It must have a no-arg constructor
  • It must have a @Id annotation
  • For our example, we used an Entity called Person however it is associated to the table called people. To do that, simply use the @Table annotation.
  • If you want to use a different name for the attributes, use the annotation @Column(name).
  • There is a @NamedQuery annotation. It is used by the Entity Manager to run a EJB-QL.

Service Layer or Business Layer

Now let’s create our Service layer. Create a Java class called PersonService into the services layer. The content looks like:

package services;
 
import java.util.List;
 
import javax.persistence.EntityManager;
 
import entities.Person;
 
public class PersonService {
    //Attributes
    private EntityManager em;
    /**
     * Constructor
     */
    public PersonService(EntityManager em) {
        this.em = em;
    }
 
    public void persistPerson(Person person) {
        em.getTransaction().begin();
        try {
            em.persist(person);
            em.getTransaction().commit();
            System.out.println("Person has been inserted successfully");
        } catch (RuntimeException re) {
            System.err.println("Error inserting the person...\n" + re.getStackTrace());
            em.getTransaction().rollback();
        }
    }
 
    @SuppressWarnings("unchecked")
    public List
 getListOfPeople() {
        return em.createNamedQuery("getListOfPeople").getResultList();
    }
}

The Service layer or Business Layer is the place where the business operation will be performed. Basically, there are two methods:

  1. persistPerson(Person person) – Persist (save) the entity into the database.
  2. getListOfPeople() – Return a java.util.List of Person. It is simliar a SELECT * FROM PEOPLE.

You can also note the EntityManager object. In JPA, it is the object responsible to manage the Entities. An entity can have four states: new, managed, detached, removed. The EntityManager manages these states.

In the persistPerson method, we have the following workflow:

  1. An transaction starts (we’re using Resource Local Transaction)
  2. Starts a Try block
  3. EntityManager tries to persist the Person object
  4. Transaction commits
  5. A success message is displayed
  6. If a Runtime Exception happen, an error message is displayed
  7. Transaction rollbacks.

Note: When you’re working in a JEE environment, you can use the JTA and container-managed transaction. Thus you cannot handle the commit/rollback yourself.

The method getListOfPeople is simpler. It simply returns a list of ALL people from the database. We’ve used the EntityManager.createNamedQuery to get the EJB-QL stored in the NamedQuery built into the Person entity.

We already have the Entity and the Service Layer. Now we need to think how the Service Layer will be called.

As you can see, the Service Layer has a EntityManager object. To avoid coupling, the EntityManager object is passed as parameter in the constructor. Hence, when the PersonService is created, the EntityManager must be passed. Looking at this scenary, we could create the PersonService through a Factory. Thus, the Factory is responsible to start the EntityManager object, start the PersonService and pass the EntityManager to it.

Factory Method

Create a file called PersonServiceFactory into services package. The content looks like:

package services;
 
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
 
public class PersonServiceFactory {
 
    public static PersonService create() {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpa_introduction");
        EntityManager em = emf.createEntityManager();
        PersonService personService = new PersonService(em);
        return personService;
    }
}

As you can see, the Factory pattern has been used. The EntityManager is created (through EntityManagerFactory.createEntityManager()).

Main Class

Finally let’s create the Main class. For our purpose, our Main class will receive some arguments from the console. If the arg[0] = “save” then persist an Person into the database. If the arg[0] = “lookup” then show up all person. Look at the code below:

package introduction;
 
import services.PersonService;
import services.PersonServiceFactory;
import entities.Person;
 
public class MainClass {
    //attribute
    private Person person;
    private PersonService personService;
 
    public static void main(String args[]) {
        MainClass main = new MainClass();
        if (args.length &lt;= 0) return;
        if (args[0].equals("save")) {
            main.insert(args);
        }
        if (args[0].equals("lookup")) {
            main.lookup();
        }
    }
    /**
     * Default Constructor
     */
    public MainClass() {
        personService = PersonServiceFactory.create();
    }
 
    private void lookup() {
        for (Person person : personService.getListOfPeople()) {
            System.out.println(person.getName() + " - " + person.getCity());
        }
    }
 
    private void insert(String args[]) {
        person = new Person();
        person.setName(args[1]);
        person.setAddress(args[2]);
        person.setCity(args[3]);
        personService.persistPerson(person);
    }
}

Nothing special though.

Running the application

To run that application, right click on MainClass -> Run As -> Run Configurations -> Arguments. Insert the following:

“save” “Jair Rillo Junior” “Av Paulista” “Sao Paulo”

Click on Run button to run the application.

If the code is correct, you should see a message in the console:

Person has been inserted successfully

Try out insert new values. Open the Run Configurations again and change the values.

After you had inserted new values, let’s see a list of people from the database. To do that, change the values and insert only one argument: “lookup” and run the application. You should see the result in the console:

Jair Rillo Junior – Sao Paulo
Batman – Gotan City
Homer Simpson – Springfield

Well, both functionality were implemented, tested and worked fine. This is the first step to get started in the JPA world.

If you want, you can download the source code here. Example from Hibernate, Example from Toplink and Example from OpenJPA. The JARs files were removed to keep the file size lesser.

Conclusion

Certainly JPA was the best specification from Java EE (although it also works in the JSE environment, as shown in this article).

Using JPA to deal with the database makes the code clear, organized and easy to maintain. As you saw, you can use exactly the same code in different implementations. JPA makes easier the change of database.

Another good point from JPA is that you can use it without a JEE environment. Even if you’re not using EJB, you can use JPA.

In short: JPA is a great specification and I advice everybody to use it in their projects.

If you have any question, fell free to leave your comment below. I hope this article be useful for anyone else.

  1. Thuy
    September 9th, 2008 at 14:06
    #1

    Hello,

    This is a very good article. I also have a question: How do you use JPA Hibernate in Websphere 6.1?

    Thanks

  2. jrjuniorsp
    September 9th, 2008 at 14:15
    #2

    Hi Thuy.

    I have been working with WAS 6.1 for a while, but I always used the OpenJPA (it is default in WAS). I didn’t try the Hibernate JPA yet, but I think if you use the required JARs files you won’t have problem. Did you try it?

    Jair Rillo Junior

  3. Thuy
    September 9th, 2008 at 14:27
    #3

    Hi Jair,

    I don’t have any problem when I use OpenJPA. However, when I switch to Hibernate, WAS is not able to initialize my EntityManager. I think that I don’t know how to config WAS to use Hibernate JPA. I have been searching for how to config WAS to use Hibernate for a couple days but I haven’t found any guide yet.

    Thuy

  4. Thuy
    September 9th, 2008 at 16:16
    #4

    This is the log output:

    00000020 CacheServiceI I DYNA1001I: WebSphere Dynamic Cache instance named ws/WSSecureMap initialized successfully.
    00000023 IscTaskProvid I IscTaskProvider provideServerInstallExtentions ear.getName app62193.ear
    00000023 IscTaskProvid I IscTaskProvider provideServerInstallExtentions Added IscEarDeployTask to Vector
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Starting workbench.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] o0742.02
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] framework search path: c:\Program Files\IBM\WebSphere\AppServer\deploytool\itp\plugins
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Creating the project.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. Opening app62193.ear.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. META-INF/ibm-application-bnd.xmi
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. META-INF/application.xml
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. lib/antlr-2.7.6.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. lib/asm-attrs.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. lib/asm.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. lib/cglib-2.1.3.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. lib/commons-collections-2.1.1.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. lib/dom4j-1.6.1.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. lib/ejb3-persistence.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. lib/hibernate-annotations.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. lib/hibernate-commons-annotations.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. lib/hibernate-entitymanager.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. lib/hibernate-search.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. lib/hibernate-validator.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. lib/hibernate3.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. lib/javassist.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. OrderSystemEJB.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. OrderSystemWeb.war
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. Updating project classpaths…
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. Importing archive ‘OrderSystemEJB.jar’. Opening OrderSystemEJB.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. Importing archive ‘OrderSystemEJB.jar’.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. Importing archive ‘OrderSystemEJB.jar’. META-INF/ejb-jar.xml
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. Importing archive ‘OrderSystemEJB.jar’. META-INF/persistence.xml
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. Importing archive ‘OrderSystemEJB.jar’. com/cgifederal/ejb3/CustomerTask.class
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. Importing archive ‘OrderSystemEJB.jar’. com/cgifederal/ejb3/CustomertaskImpl.class
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. Importing archive ‘OrderSystemEJB.jar’. com/cgifederal/ejb3/IMyBean.class
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. Importing archive ‘OrderSystemEJB.jar’. com/cgifederal/ejb3/MyBean.class
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. Importing archive ‘OrderSystemEJB.jar’. com/cgifederal/ejb3/MyBeanLocal.class
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. Importing archive ‘OrderSystemEJB.jar’. com/cgifederal/ejb3/MyBeanRemote.class
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. Importing archive ‘OrderSystemEJB.jar’. com/cgifederal/oss/model/Customers.class
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. Importing archive ‘OrderSystemEJB.jar’. com/cgifederal/oss/model/Orders.class
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’. Importing archive ‘OrderSystemEJB.jar’.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Importing archive ‘C:\Temp\app62193.ear’.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Deploying jar OrderSystemEJB
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Generating deployment code
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Refreshing /OrderSystemEJB/ejbModule.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Invoking Java Builder on /OrderSystemEJB.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Preparing to build OrderSystemEJB
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Cleaning output folder for OrderSystemEJB
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Copying resources to the output folder
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Analyzing sources
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Build done
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Invoking Faceted Project Validation Builder on /OrderSystemEJB.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Invoking Validation on /OrderSystemEJB.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Invoking Faceted Project Validation Builder on /app62193.ear.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Invoking Validation on /app62193.ear.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Invoking RMIC.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Writing output file
    00000027 DeployEJBTask I ADMA0158I: [EJBDeploy] Sep 9, 2008 12:12:10 PM com.ibm.etools.ejbdeploy.logging.Logger logInfo
    00000027 DeployEJBTask I ADMA0158I: [EJBDeploy] INFO: 0 class files
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Refreshing /app62193.ear.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. lib/hibernate-annotations.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. lib/hibernate-entitymanager.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. lib/dom4j-1.6.1.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. OrderSystemWeb.war
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. com/cgifederal/oss
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. com/cgifederal/ejb3/CustomerTask.class
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. com/cgifederal/oss/model/Customers.class
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. com/cgifederal/ejb3/IMyBean.class
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. META-INF/ibm_ejbext.properties
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. com/cgifederal/ejb3/MyBeanLocal.class
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. META-INF/MANIFEST.MF
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. META-INF/persistence.xml
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. META-INF
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. com/cgifederal
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. com/cgifederal/ejb3/CustomertaskImpl.class
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. com/cgifederal/oss/model
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. com/cgifederal/oss/model/Orders.class
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. com/cgifederal/ejb3/MyBean.class
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. com/cgifederal/ejb3/MyBeanRemote.class
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. com
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. META-INF/ejb-jar.xml
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’. com/cgifederal/ejb3
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. Exporting archive ‘OrderSystemEJB.jar’.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. lib/cglib-2.1.3.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. META-INF/ibm-application-bnd.xmi
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. lib
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. lib/ejb3-persistence.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. lib/asm-attrs.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. lib/asm.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. lib/hibernate3.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. lib/commons-collections-2.1.1.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. META-INF
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. lib/antlr-2.7.6.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. META-INF/application.xml
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. lib/javassist.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. lib/hibernate-search.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. lib/hibernate-validator.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’. lib/hibernate-commons-annotations.jar
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Exporting archive ‘dpl_OrderSystem.ear’.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] Shutting down workbench.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] EJBDeploy complete.
    00000025 DeployEJBTask I ADMA0158I: [EJBDeploy] 0 Errors, 0 Warnings, 0 Informational Messages
    00000023 WSDeployTask A WSWS0041I: Web services deploy task completed successfully.
    00000023 IscEarDeployT I IscEarDeployTask performTask Earfile:dpl_OrderSystem
    00000023 IscEarDeployT I IscEarDeployTask performTask Path:C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\wstemp\wstemp\app_11c47e2379b\dpl\ws\dpl_OrderSystem
    00000022 FileRepositor A ADMR0015I: User defaultWIMFileBasedRealm/admin created document cells/THUYNGU-076317Node01Cell/applications/OrderSystem.ear/deployments/OrderSystem/META-INF/application.xml.
    00000022 FileRepositor A ADMR0015I: User defaultWIMFileBasedRealm/admin created document cells/THUYNGU-076317Node01Cell/applications/OrderSystem.ear/deployments/OrderSystem/OrderSystemWeb.war/WEB-INF/ibm-web-ext.xmi.
    00000022 FileRepositor A ADMR0015I: User defaultWIMFileBasedRealm/admin created document cells/THUYNGU-076317Node01Cell/applications/OrderSystem.ear/deployments/OrderSystem/META-INF/MANIFEST.MF.
    00000022 FileRepositor A ADMR0015I: User defaultWIMFileBasedRealm/admin created document cells/THUYNGU-076317Node01Cell/applications/OrderSystem.ear/deployments/OrderSystem/OrderSystemWeb.war/META-INF/MANIFEST.MF.
    00000022 FileRepositor A ADMR0015I: User defaultWIMFileBasedRealm/admin created document cells/THUYNGU-076317Node01Cell/applications/OrderSystem.ear/deployments/OrderSystem/OrderSystemEJB.jar/META-INF/persistence.xml.
    00000022 FileRepositor A ADMR0015I: User defaultWIMFileBasedRealm/admin created document cells/THUYNGU-076317Node01Cell/applications/OrderSystem.ear/deployments/OrderSystem/OrderSystemEJB.jar/META-INF/MANIFEST.MF.
    00000022 FileRepositor A ADMR0015I: User defaultWIMFileBasedRealm/admin created document cells/THUYNGU-076317Node01Cell/applications/OrderSystem.ear/OrderSystem.ear.
    00000022 FileRepositor A ADMR0015I: User defaultWIMFileBasedRealm/admin created document cells/THUYNGU-076317Node01Cell/applications/OrderSystem.ear/deployments/OrderSystem/deployment.xml.
    00000022 FileRepositor A ADMR0015I: User defaultWIMFileBasedRealm/admin created document cells/THUYNGU-076317Node01Cell/applications/OrderSystem.ear/deployments/OrderSystem/OrderSystemWeb.war/WEB-INF/ibm-web-bnd.xmi.
    00000022 FileRepositor A ADMR0015I: User defaultWIMFileBasedRealm/admin created document cells/THUYNGU-076317Node01Cell/applications/OrderSystem.ear/deployments/OrderSystem/OrderSystemEJB.jar/META-INF/ibm_ejbext.properties.
    00000022 FileRepositor A ADMR0015I: User defaultWIMFileBasedRealm/admin created document cells/THUYNGU-076317Node01Cell/applications/OrderSystem.ear/deployments/OrderSystem/META-INF/ibm-application-bnd.xmi.
    00000022 FileRepositor A ADMR0015I: User defaultWIMFileBasedRealm/admin created document cells/THUYNGU-076317Node01Cell/applications/OrderSystem.ear/deployments/OrderSystem/OrderSystemEJB.jar/META-INF/ejb-jar.xml.
    00000022 FileRepositor A ADMR0015I: User defaultWIMFileBasedRealm/admin created document cells/THUYNGU-076317Node01Cell/applications/OrderSystem.ear/deltas/OrderSystem/delta-1220976733310.
    00000022 FileRepositor A ADMR0015I: User defaultWIMFileBasedRealm/admin created document cells/THUYNGU-076317Node01Cell/applications/OrderSystem.ear/deployments/OrderSystem/OrderSystemWeb.war/WEB-INF/web.xml.
    00000022 FileRepositor A ADMR0016I: User defaultWIMFileBasedRealm/admin modified document cells/THUYNGU-076317Node01Cell/nodes/THUYNGU-076317Node01/serverindex.xml.
    00000020 ApplicationMg A WSVR0200I: Starting application: OrderSystem
    00000020 ApplicationMg A WSVR0204I: Application: OrderSystem Application build level: Unknown
    00000020 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl initialize FFDC0009I: FFDC opened incident stream file C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\ffdc\server1_00000020_08.09.09_12.12.19_0.txt
    00000020 ServiceLogger I com.ibm.ws.ffdc.IncidentStreamImpl resetIncidentStream FFDC0010I: FFDC closed incident stream file C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\ffdc\server1_00000020_08.09.09_12.12.19_0.txt
    00000020 JPAPUnitInfo E CWWJP0009E: The server cannot create an EntityManangerFactory factory for the OrderSystemEJBPU persistent unit from the org.hibernate.ejb.HibernatePersistence provider in jar:file:/C:/Program Files/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/THUYNGU-076317Node01Cell/OrderSystem.ear/OrderSystemEJB.jar!/ modul
    00000020 EJBContainerI I WSVR0037I: Starting EJB jar: OrderSystemEJB.jar
    00000020 EJBContainerI I CNTR0167I: The server is binding the IMyBean interface of the MyBean enterprise bean in the OrderSystemEJB.jar module of the OrderSystem application. The binding location is: ejblocal:OrderSystem/OrderSystemEJB.jar/MyBean#com.cgifederal.ejb3.IMyBean
    00000020 EJBContainerI I CNTR0167I: The server is binding the IMyBean interface of the MyBean enterprise bean in the OrderSystemEJB.jar module of the OrderSystem application. The binding location is: ejblocal:com.cgifederal.ejb3.IMyBean
    00000020 EJBContainerI I CNTR0167I: The server is binding the CustomerTask interface of the CustomertaskImpl enterprise bean in the OrderSystemEJB.jar module of the OrderSystem application. The binding location is: ejblocal:OrderSystem/OrderSystemEJB.jar/CustomertaskImpl#com.cgifederal.ejb3.CustomerTask
    00000020 EJBContainerI I CNTR0167I: The server is binding the CustomerTask interface of the CustomertaskImpl enterprise bean in the OrderSystemEJB.jar module of the OrderSystem application. The binding location is: ejblocal:com.cgifederal.ejb3.CustomerTask
    00000020 EJBContainerI I WSVR0057I: EJB jar started: OrderSystemEJB.jar
    00000020 WebGroup A SRVE0169I: Loading Web Module: OrderSystemWeb.war.
    00000020 JPAPUnitInfo E CWWJP0009E: The server cannot create an EntityManangerFactory factory for the OrderSystemEJBPU persistent unit from the org.hibernate.ejb.HibernatePersistence provider in jar:file:/C:/Program Files/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/THUYNGU-076317Node01Cell/OrderSystem.ear/OrderSystemEJB.jar!/ modul
    00000020 VirtualHost I SRVE0250I: Web Module has been bound to default_host[*:9080,*:80,*:9443,*:5060,*:5061,*:443].
    00000020 ApplicationMg A WSVR0221I: Application started: OrderSystem
    00000022 ApplicationMg A WSVR0217I: Stopping application: OrderSystem
    00000022 EJBContainerI I WSVR0041I: Stopping EJB jar: OrderSystemEJB.jar
    00000022 EJBContainerI I WSVR0059I: EJB jar stopped: OrderSystemEJB.jar
    00000022 ApplicationMg A WSVR0220I: Application stopped: OrderSystem
    00000022 ApplicationMg A WSVR0200I: Starting application: OrderSystem
    00000022 ApplicationMg A WSVR0204I: Application: OrderSystem Application build level: Unknown
    00000022 JPAPUnitInfo E CWWJP0009E: The server cannot create an EntityManangerFactory factory for the OrderSystemEJBPU persistent unit from the org.hibernate.ejb.HibernatePersistence provider in file:/C:/Program Files/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/THUYNGU-076317Node01Cell/OrderSystem.ear/OrderSystemEJB.jar/ module.
    00000022 EJBContainerI I WSVR0037I: Starting EJB jar: OrderSystemEJB.jar
    00000022 EJBContainerI I CNTR0167I: The server is binding the IMyBean interface of the MyBean enterprise bean in the OrderSystemEJB.jar module of the OrderSystem application. The binding location is: ejblocal:OrderSystem/OrderSystemEJB.jar/MyBean#com.cgifederal.ejb3.IMyBean
    00000022 EJBContainerI I CNTR0167I: The server is binding the IMyBean interface of the MyBean enterprise bean in the OrderSystemEJB.jar module of the OrderSystem application. The binding location is: ejblocal:com.cgifederal.ejb3.IMyBean
    00000022 EJBContainerI I CNTR0167I: The server is binding the CustomerTask interface of the CustomertaskImpl enterprise bean in the OrderSystemEJB.jar module of the OrderSystem application. The binding location is: ejblocal:OrderSystem/OrderSystemEJB.jar/CustomertaskImpl#com.cgifederal.ejb3.CustomerTask
    00000022 EJBContainerI I CNTR0167I: The server is binding the CustomerTask interface of the CustomertaskImpl enterprise bean in the OrderSystemEJB.jar module of the OrderSystem application. The binding location is: ejblocal:com.cgifederal.ejb3.CustomerTask
    00000022 EJBContainerI I WSVR0057I: EJB jar started: OrderSystemEJB.jar
    00000022 WebGroup A SRVE0169I: Loading Web Module: OrderSystemWeb.war.
    00000022 JPAPUnitInfo E CWWJP0009E: The server cannot create an EntityManangerFactory factory for the OrderSystemEJBPU persistent unit from the org.hibernate.ejb.HibernatePersistence provider in file:/C:/Program Files/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/THUYNGU-076317Node01Cell/OrderSystem.ear/OrderSystemEJB.jar/ module.
    00000022 VirtualHost I SRVE0250I: Web Module has been bound to default_host[*:9080,*:80,*:9443,*:5060,*:5061,*:443].
    00000022 ApplicationMg A WSVR0221I: Application started: OrderSystem

  5. jrjuniorsp
    September 9th, 2008 at 20:33
    #5

    Hi Thuy,
    I’ve create myself a simple Web Application on Websphere using the Hibernate implementation and for my surprise it didn’t work :(.
    Looking at google I found this: http://www-128.ibm.com/developerworks/forums/thread.jspa?threadID=182253. Although it is an old message (from Nov-19-2007), it seems the Websphere team did not fix the integration of alternate JPA provider yet.

    Also, I’ve tested with Toplink and I got the same problem (argh). We’ve to use the OpenJPA implementation for time being. Fortunately this implementation looks good also (at least for me).

  6. Thuy
    September 10th, 2008 at 13:47
    #6

    Hi Jrjuniorsp,

    I finally made it working. I have to import some basic jars file to EAR project. Then I have to modify the classpath in Manifest file to make it work. What is a pain !

  7. jrjuniorsp
    September 10th, 2008 at 13:56
    #7

    Hey Thuy,

    What a great news!! I tried it yesterday but I had no success. Could you send me the which JARs files and which modification you did to Hibernate work? If you prefer send me those information by email “jrjuniorsp (at) yahoo (dot) com (dot) br

    Thanks

  8. Thuy
    September 10th, 2008 at 15:56
    #8

    I sent you an email and I got return :(. I will copy the email here:

    Hey jrjuniorsp,
    Attached is the list of all jar file I import to EAR project.

    These libraries are from:

    1. hibernate-annotations-3.4.0.GA
    2. hibernate-distribution-3.3.0.SP1
    3. hibernate-entitymanager-3.4.0.GA

    List of libs:
    antlr-2.7.6.jar
    commons-collections-3.1.jar
    dom4j-1.6.1.jar
    dom4j.jar
    ejb3-persistence.jar
    hibernate3.jar
    hibernate-annotations.jar
    hibernate-commons-annotations.jar
    hibernate-entitymanager.jar
    javassist-3.4.GA.jar
    jta-1.1.jar
    log4j-1.2.15.jar
    slf4j-api-1.4.2.jar
    slf4j-log4j12.jar

    You also need to modify MANIFEST.MF as follow:

    Manifest-Version: 1.0
    Class-Path: ./lib/hibernate-entitymanager.jar;./lib/hibernate3.jar;./lib/ejb3-persistence.jar;./lib/slf4j-api-1.4.2.jar;./lib/slf4j-log4j12.jar./lib/log4j-1.2.15.jar

    Additional:

    Now I am trying to use genericDAO with JPA and deploy it on WAS. However, it does not initialize EntityManger that I put in the implementation of GenericDao:

    @PersistenceContext(name=”OrderSystemEJBPU”, type=PersistenceContextType.EXTENDED)
    public void setEntityManager(EntityManager entityManager) {
    this.entityManager = entityManager;
    }

    Do you have any idea ?

    Thanks

  9. Jair Rillo Junior
    September 10th, 2008 at 19:32
    #9

    Hey Thuy

    I tried it but no success. I’m certain that Hibernate or any other JPA implementation different than the default OpenJPA don’t work at WAS.
    Firstly, I’ve created the code using OpenJPA. After that, I put the Hibernate required libs and changed the persistence.xml file (like you said). The problem happens when the Container tries to INJECT the EntityManager (java.lang.NullPointerException).

    As the Websphere guy said in the link I sent you, “only OpenJPA is working in WAS” (and it seems that problem wasn’t fixed yet)

  10. Thuy
    September 10th, 2008 at 21:17
    #10

    Hello,

    It is working at this moment for me. From the output of WAS, I can see that it uses the Hibernate provider not the OPENJPA. At the beginning, I have the NullPointerException when it tries to INJECT EntityManager. After putting the jar files and and modify MEATFEST.MF , things are working.

  11. Thuy
    September 10th, 2008 at 21:18
    #11

    Again,

    Did you install the Feature Pack to WAS ?

  12. Jair Rillo Junior
    September 10th, 2008 at 21:27
    #12

    Yes.. I’ve installed Feature Pack. As I said you, it’s working with OpenJPA.
    I put the JARs file in a lib directory into EAR project.
    Also, I’ve changed the MANIFEST.MF (from EJB Project)
    When I try @PersistenceContext private EntityManager em; // I got Exception at this poing

    Did you put the JARs in the EAR project and modified the MANIFEST.MF in the EJB Project as well?

  13. Jair Rillo Junior
    September 10th, 2008 at 21:47
    #13

    For me, the JPA Hiberante wasn’t started by WAS.. look at the messages I got:

    [9/10/08 18:45:30:393 BRT] 0000000a JPAComponentI I CWWJP0026I: The Java Persistence API (JPA) component is initializing.
    [9/10/08 18:45:30:415 BRT] 0000000a JPAComponentI I CWWJP0006I: The com.ibm.websphere.persistence.PersistenceProviderImpl class is loaded as the default Java Persistence API (JPA) provider.
    [9/10/08 18:45:30:417 BRT] 0000000a JPAComponentI I CWWJP0027I: The Java Persistence API (JPA) component has initialized.

    WAS is still using its default provider “com.ibm.websphere.persistence.PersistenceProviderImpl”

  14. Thuy
    September 11th, 2008 at 13:43
    #14

    give me your email I will send to a zip file of the sample project.

  15. Thuy
    September 11th, 2008 at 13:44
    #15

    You need to change the MANIFEST from EAR not from EJB project.

  16. Raj
    September 19th, 2008 at 13:17
    #16

    Any clue to the below problem, is it related to the some jars not in path, I have put almost all hibernate 3.2 jars not 3.3.

    Exception in thread “main” java.lang.NoClassDefFoundError: org/jboss/util/file/ArchiveBrowser$Filter
    at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:119)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
    at services.PersonServiceFactory.create(PersonServiceFactory.java:10)
    at introduction.MainClass.(MainClass.java:28)
    at introduction.MainClass.main(MainClass.java:15)

  17. Jair Rillo Junior
    September 19th, 2008 at 13:59
    #17

    Hey Raj,

    Unfortunately each version of Hibernate uses a set of different Jars. I recommend you to check out the official documentation directly (it brings with the Hibernate-core). I do not use Hibernate 3.2 anymore, so I cannot help you

  18. Marcelo Sousa Ancelmo
    October 28th, 2008 at 11:22
    #18

    Hi Jair, first of all, great article.

    To use Hibernate as an JPA implementatio in WAS, you need to configure a shared library in WAS using the jar’s listed by Thuy. Then you just need to apply this shared library to your EAR.

    Regards,
    Marcelo Sousa Ancelmo

  19. Filip
    December 4th, 2008 at 10:58
    #19

    Hi Jair, the article is great indeed.
    I’m dealing with the same problem you’ve been dealing some time ago. Did you finally make it work? I’ve read you have some working sample. Can you send me that?

    Regards,
    Filip

  20. December 19th, 2008 at 08:43
    #20

    Sorry for the delay Filip.
    Actually, I had no time to test the Hibernate implementation into WAS. I moved to a new project and I’m really busy. (neither new articles I have time to write out). Sorry man

  21. February 23rd, 2009 at 05:21
    #21

    useful info…

  22. August 17th, 2009 at 01:26
    #22

    Is needed jboss-archive-browsing and jboss-common.jar in your lib directory

  23. August 17th, 2009 at 20:04
    #23

    Hi Diego,
    If you’re using Toplink or OpenJPA implementation you certainly do not need these two JAR files, however for Hibernate implementation I’m not sure. Maybe in new version of Hibernate these two files are required, but you must test out to make sure.

  24. Sujeeth
    June 9th, 2011 at 09:33
    #24

    Deal All,

    I am also facing with the same issue, deploying the hibernate as JPA implementation in WAS 6.1.0.31 with EJB3 Feature pack installed.

    I did kept the jar files listed by Thuy in my EAR. But no luck :(.

    I get following exception :

    [6/9/11 14:27:53:696 CEST] 00000023 SystemErr R WARNING: Found unrecognized persistence provider “org.hibernate.ejb.HibernatePersistence” in place of OpenJPA provider. This provider’s properties will not be used.

    Pls. help me.

    Thanks,
    Sujeeth

  25. June 13th, 2011 at 11:39
    #25

    Hey there, I think your website might be having browser compatibility issues. When I look at your website in Firefox, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, excellent blog!

  26. October 9th, 2012 at 04:23
    #26

    Abraham Lincoln stated with the Civil War “… this nation, underneath God, shall have a very new birth of freedomand that govt on the folks, with the men and women, for that men and women, shall not perish from your earth.”

TOP