I'm using a JAR which contains only a ClassPath element to build the classpath for my Java app and I've encountered a weird behavior: I can load classes from the JARs mentioned in the ClassPath element but some (or all) resources are missing.
Example: My full-classpath.jar contains just a META-INF/MANIFEST.MF with the usual content and this line:
ClassPath: foo-service.jar bar-service.jar service-main.jar
service-main.jar contains com.pany.project.Main.
When I run java -cp full-classpath.jar com.pany.project.Main, that works.
But foo-service.jar and bar-service.jar contain service definitions in META-INF/services/....
When I invoke java.util.ServiceLoader from a Maven unit test, it can see both the foo and the bar service. When I java -cp full-classpath.jar com.pany.project.Main -service foo, I see an empty service list in my log.
Worse, when I call Main.class.getClassLoader().getResources("META-INF/MANIFEST.MF"), I get only the manifest from full-classpath.jar. The manifest files from the other three JARs are missing which doesn't make sense since I can load classes from those JARs! It also works when I build the whole classpath manually. It only fails when I use the ClassPath element in the full-classpath.jar.
Any ideas what could be wrong or how I could debug this?
I'm using Java 8.