Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA Implementation difference between Glassfish and JBoss

 
Sriram Kannan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have been doing some learning on server-specific details to be followed during the deployment of J2EE applications. So far, my choices have been Glassfish and JBoss (open source, being the first criteria :-) ).

But, I am kinda stuck while working with entities in both the servers. I am using the same database and have set them in the DD of both the servers.

My testing sample is a simple Stateless Session Bean trying to create an Entity (which in turn will create 2 other Entities, if they are not available already). I am trying to find if the Entity is already available using the entityManager.find(EntityClass, Primary Key). The Primary Key of the entity for which the persist is called is set manually. For the other 2 entities, the ID Generation is AUTO.

All I am doing is injecting the PersistenceContext (which by default is the Persistence Context pertaining to the server, I believe), creating a POJO and after setting all the properties, persisting using entityManager.persist(Entity e). The Entity also has a CASCADE annotation that persists the other 2 entities automatically.

In glassfish v2.1, it is smooth as butter and I am able to test it perfectly.

But, in JBoss v4.2, it throws an exception of

javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: entity.EntityA

The exception is thrown even for the first time the client runs. What is missing here ?

Also, is there any server specific configuration has to be done other than configuring the DataSource in their own DDs ?

I can see the underlying exception in JBoss is with Hibernate. I do not have much knowledge about the nuances of the framework. I hope it is not necessary for a simple JPA testing ?

Thanks a lot in advance :-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic