Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Spring fails to locate jar files defined with jar-file tag in persistence.xml [SPR-9797] #14430
I have a JPA2 persistence.xml containing the following jar file definition for a persistence unit:
My application (MyApp) is a standard ear running in WebSphere 8. The persistence.xml is located in MyApp.ear/MyApp.war/WEB-INF/classes/META-INF as the JPA2 specification requires.
The common-domain-1.2.0-SNAPSHOT.jar is located in MyApp.ear/MyApp.war/WEB-INF/lib.
This setup is in line with the JPA2 specification section 220.127.116.11.3. There is even an example (Example 5) specifically showing this situation.
When Spring reads in the persistence unit configuration, it fails with the exception:
java.io.FileNotFoundException: ServletContext resource [/lib/common-domain-1.2.0-SNAPSHOT.jar] cannot be resolved to URL because it does not exist
As you can see, there is an additional path separator in front of the path, so to me this is clearly a bug. This setup should work as per the JPA2 specification. There is a forum post also about this: http://forum.springsource.org/showthread.php?78109-jar-file-tag-can-not-locate-the-classpath-in-persistence-xml
Juergen Hoeller commented
This should work fine now with a dedicated code path that falls back to spec-compliant lookup relative to the persistence unit root, for the case where the location wasn't resolvable using Spring's resource pattern mechanism.