| 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
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" excluding the protocol, thus resulting in "META-INF/persistence.xml", without the initial "/". Is it possible to use hibernate from a runnable jar packaged this way? A warkaround is to change package strategy to "Extract required libraries into generated JAR", but this mix libraries with actual user code, and I would prefer to keep them separated. |