Today I tracked down a nasty bug in Eclipselink JPA. To my upmost surprise this seems to be a problem with the classloader in Java. If the executing class is in a very deep path, e.g. C:\Documents and Settings\vogella1\Desktop\Documents8_MyDocuments\20_Documentation\WebpageExamples\de.vogella.jpa.bug\bin then the classloader does not find a resource in this class.
If you want to give it a try, below you find a small test class. I reported this at bugs.sun.com and got an incident number. So I have to wait what Suns says about this issue.
———————————————–
package de.vogella.jpa.bug;
import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
public class Test {
public static void main(String[] args) {
ClassLoader currentLoader = Thread.currentThread()
.getContextClassLoader();
try {
Enumeration resources = currentLoader
.getResources(“META-INF/persistence.xml”);
while (resources.hasMoreElements()) {
System.out.println(“Elements found”);
resources.nextElement();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}