I'm trying to use <jar-file> element in a persistence.xml of an EAR deployed on JBoss 6.1.0.Final.
As stated in JPA 2.0 specs, one or more JAR files may be specified using the jar-file elements. These jar files contains classes annotated with @Entity.
According to the JPA 2.0 Specification 220.127.116.11.3:
One or more JAR files may be specified using the jar-file elements instead of, or in addition to the mapping files specified in the mapping-file elements. If specified, these JAR files will be searched for managed persistence classes, and any mapping metadata annotations found on them will be processed, or they will be mapped using the mapping annotation defaults defined by this specification. Such JAR files are specified relative to the directory or jar file that contains the root of the persistence unit.
The following examples illustrate the use of the jar-file element to reference additional persistence classes. These examples use the convention that a jar file with a name terminating in “PUnit” contains the persistence.xml file and that a jar file with a name terminating in “Entities” contains additional persistence classes.
lib/earRootPUnit.jar (with META-INF/persistence.xml )
I follow the example of JPA specs, but the entity contained in earEntities.jar are not loaded. Enabling DEBUG level for org.hibernate, I see:
DEBUG [org.hibernate.ejb.Ejb3Configuration] (HDScanner) Processing PersistenceUnitInfo [
persistence provider classname: org.hibernate.ejb.HibernatePersistence
Temporary classloader: null
JTA datasource: org.jboss.resource.adapter.jdbc.WrapperDataSource@71ff36c5
Non JTA datasource: org.jboss.resource.adapter.jdbc.WrapperDataSource@71ff36c5
Transaction type: JTA
PU root URL: vfs:/D:/opt/jboss-6.1.0.Final/server/default/deploy/myApp.ear/lib/earRootPUnit.jar/
Shared Cache Mode: null
Validation Mode: null
Jar files URLs [
Managed classes names 
Mapping files names 
The path of jar is relative to the deploy directory of the AS, not to the directory or jar file that contains the root of the persistence unit, as stated in JPA specs.
If I change my jar-file path to:
jar is found and entity are loaded into persistence loaded.
But this seems in contrast with JPA specs and it is not good for my needs because I'd like to avoid to use the name of EAR if the persistence.xml.
Someone can give me some information on which is the correct way to use relative paths in <jar-file>?
Thanks to all!