Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring fails to locate jar files defined with jar-file tag in persistence.xml [SPR-9797] #14430

Closed
spring-projects-issues opened this issue Sep 14, 2012 · 1 comment
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Sep 14, 2012

Panu Bloigu opened SPR-9797 and commented

I have a JPA2 persistence.xml containing the following jar file definition for a persistence unit:

<jar-file>lib/common-domain-1.2.0-SNAPSHOT.jar</jar-file>

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 8.2.1.6.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
at org.springframework.web.context.support.ServletContextResource.getURL(ServletContextResource.java:154)
at org.springframework.orm.jpa.persistenceunit.PersistenceUnitReader.parseJarFiles(PersistenceUnitReader.java:329)
at org.springframework.orm.jpa.persistenceunit.PersistenceUnitReader.parsePersistenceUnitInfo(PersistenceUnitReader.java:281)
at org.springframework.orm.jpa.persistenceunit.PersistenceUnitReader.parseDocument(PersistenceUnitReader.java:179)
at org.springframework.orm.jpa.persistenceunit.PersistenceUnitReader.readPersistenceUnitInfos(PersistenceUnitReader.java:132)

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


Affects: 3.1.2

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Oct 10, 2012

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.

Juergen

@spring-projects-issues spring-projects-issues added type: bug A general bug in: data Issues in data modules (jdbc, orm, oxm, tx) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.1.3 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants