persistence@glassfish.java.net

JPA packaging

From: Peter Krogh <peter.krogh_at_oracle.com>
Date: Tue, 23 Jan 2007 13:27:33 -0500

Hi,

There is a packaging issue that some of us started talking about on the phone, and we agreed to bounce this around the alias.

We have seen a problem when bundling Spring and TLE in a Tomcat web app, and using annotations on entity classes. If the weaver is being used (as it is by default) the deployment will run into a problem that is manifested by TopLink not recognizing any of the annotations. This is brought on because:

- Web loaders check locally before they check in the parent loaders for classes
- TLE packages the JPA annotations in toplink-essentials.jar
- The weaver uses the temporary class loader to look for entity classes

The solution so far is to take toplink-essentials.jar out of the war and placing it on the Tomcat server classpath. Other (more intrusive) ways to resolve the problem are:

- not use annotations
- turn off weaving
- not use the container-API, just the bootstrap API
- delete the annotations from the toplink-essentials.jar and put them in a jar on the server classpath

The solution of having to put the TopLink Essentials jar on the Tomcat server classpath is really not a very friendly answer.

What would be involved in taking the annotations out of toplink-essentials.jar?