I have a standalone appliaction packaged as a runnable jar. The jar is created from Eclipse with the "Package required libraries into generated JAR" option, dependencies of the project are manged with Maven.
Running the jar I get the following exception
The final jar includes some classes from Eclipse to leverage a JarInJarLoader, which basically handles loading of jars included directly inside the resulting jar. This loader registers an rsrc: protocol which is considered by the Hibernate bootstrap process, so when it gets to the
method at line 45 it tries to substring the "file" variable from beginning up to "file.lenght() - entry.length()" which is a negative number (exactly -1 as reported in the exception) because entry is the string "/META-INF/persistence.xml", while file is taken from the url "rsrc:/META-INF/persistence.xml" getting the file part of the url, thus resulting in "META-INF/persistence.xml" (without the initial "/" with respect to "entry" variable value).
Is it possible to use hibernate from a runnable jar packaged this way? A workaround is to change package strategy to "Extract required libraries into generated JAR", but this mixes up libraries' binaries with actual user code, and I would prefer to keep them separated.
Java 8, Hibernate 5.2.12.Final