[hibernate-dev] The PAR archive test case validity - PackagedEntityManagerTest
Vlad Mihalcea
mihalcea.vlad at gmail.com
Wed Mar 9 10:05:07 EST 2016
Hi,
I have two tests in the PackagedEntityManagerTest unit test that fail on my
machine, but work just fine for everybody else.
It could be an OS thing or not, but during the check, I found hat we are
testing against an use case that is not found in the JPA spec.
The testExternalJar() creates an externaljar.jar and an explicitpar.par.
I found an old reference on the PAR archive (
http://radio-weblogs.com/0135826/2005/07/07.html) but the JPA 2.1 doesn't
mention anything about it.
The explicitpar.par contains the persistence.xml which contains a jar-file
attribute that references the externaljar.jar with an absolute path:
<jar-file>D:\Vlad\Work\GitHub\hibernate-orm\hibernate-entitymanager\target/packages/externaljar.jar</jar-file>
The JPA spec says that: "Such JAR files are specified relative to the
directory or jar file that contains the root of the persistence unit", and
gives several examples
for when using an EAR with or without a WAR.
While debugging, I found that the JarFileBasedArchiveDescriptor scans the
"explicitpar.par" and looks for:
if ( getEntryBasePrefix() != null && ! entryName.startsWith(
getEntryBasePrefix() ) ) {
continue;
}
where the getEntryBasePrefix() is
"D:/Vlad/Work/GitHub/hibernate-orm/hibernate-entitymanager/target/packages/externaljar.jar"
The way that JarFileBasedArchiveDescriptor is implemented matches the JPA
description.
Nevertheless, the scan cannot locate the jar, and the entities that are
contained in the "externaljar.jar" don't get loaded, and the test fails.
I can ignore this on my machine and just consider it a white noise, but I
wonder why we still check for PAR when we might want to have a test with an
EAR instead and relative paths.
Vlad
More information about the hibernate-dev
mailing list