Saturday, November 6, 2010


This UML Class diagram describes a portion of the EclipseLink 2.0 API both internal and external classes and interfaces and more specifically the JPA 2.0 Metamodel API

This UML Sequence diagram illustrates the core of batch writing in EclipseLink

Figure: EclipseLink UML Sequence Diagram : Batch Query

UML Source : Microsoft Visio 2000 VSD format hosted on the Amazon S3 cloud

Thursday, November 4, 2010

JPA based Enterprise Applications on EE Application Server Containers

20110115: WebLogic Server 10.3.4 has been released with support for JPA 2.0 (JSR-317)

See for more info.

   First things first - configuration....
HSQL 1.8/2.0 (Hypersonic)
startup script
# java -cp ../lib/hsqldb.jar org.hsqldb.Server -database.0 file:mydb -dbname.0 xdb

Persistence.xml fragment


WebLogic Console and JPA Persistence Providers:
    WebLogic ships with support for JPA providers such as EclipseLink and Kodo.  In order to use EclipseLink you will either want to set the <provider> to org.eclipse.persistence.jpa.PersistenceProvider or enable EclipseLink as the default JPA provider for your WebLogic domain.
    Once your EE application is deployed, you may view which persistence units are available either as container managed persistence units via the EJB container or application managed units via the Web container.

 Extended properties such as the container defined JTA data source here can be verified here as well.

GlassFish JPA Deployment:

   EJB module ordering in the application.xml deployment descriptor of your EE EAR is significant in GlassFish - See EclipseLink bug 323148 and comment # 9 of EclipseLink bug 293191. This issue is that weaving/bytecode-instrumentation will not have been run yet on the persistence unit in an EJB module if the WAR module that uses/injects a session bean (itself injected with a persistence context) is processed first.  This EAR module order in the order of use looks to only be an issue with JSF applications. 

Debugging JPA container managed transactional applications in WebLogic Server from Eclipse
If you are regularly debugging client EE or server code running on WebLogic server from an IDE like Eclipse Galileo - you will need to increase the default transaction timeout from 30 seconds to something like 300n seconds.
Otherwise you will see a transaction timout exception like the following - for example during a standard entityManager persist on a stateless session bean that uses a transactional @PersistenceContext injection of the persistence unit.

javax.ejb.EJBException: Transaction Rolledback.: weblogic.transaction.internal.TimedOutException: Transaction timed out after 34 seconds
 at weblogic.transaction.internal.ServerTransactionImpl.wakeUp(
 at weblogic.transaction.internal.ServerTransactionManagerImpl.processTimedOutTransactions(
 at weblogic.transaction.internal.TransactionManagerImpl.wakeUp(
 at weblogic.transaction.internal.ServerTransactionManagerImpl.wakeUp(
 at weblogic.transaction.internal.WLSTimer.timerExpired(
nested exception is: weblogic.transaction.internal.TimedOutException: Transaction timed out after 34 seconds 
 at weblogic.ejb.container.internal.EJBRuntimeUtils.throwEJBException(
 at weblogic.ejb.container.internal.BaseLocalObject.postInvoke1(
 at weblogic.ejb.container.internal.BaseLocalObject.__WL_postInvokeTxRetry(
 at org.eclipse.persistence.example.jpa.server.weblogic.enterprise.presentation.FrontController.processGliderCommand(

The following WebLogic console page is used to increase the transaction timeout : Domain|Configuration|JTA

Tomcat Deployment:
Even though Tomcat is only a web container and does not supply a transactional EJB container - we can still deploy JPA applications using application managed sessions.

64 Bit Tomcat: Since tomcat is almost entirely a java application and therefore uses 32/64 bit agnostic bytecode we can run either version on 64 bit operating systems.  The only difference between the 32 and 64 bit versions of tomcat is for the non-java based windows services executable and dll (tcnative-1.dll and tomcat7.exe).  If you run tomcat from the command line then both versions are the same.


Referencing Remote Persistence Archives:
Normally the persistence classes (Entities, MappedSuperclasses, Embeddables and Transient classes) are either part of the module containing the persistence.xml descriptor or in a separate jar that is packaged with the application (whether standalone SE or server based EE).

1) Separate Entity jar
For example, in the client SE jar we define persistence.xml in the location /src/META-INF/persistence.xml and reference entities that can be shared between modules.


Total Pageviews