Exception "Unable to resolve Jdbc Java migrations in location" due to wrong assumption on classloader behavior #1487
What version of Flyway are you using?
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin, SBT plugin, ANT tasks)
Java API (JRE 126.96.36.199)
What database are you using (type & version)?
What operating system are you using?
Windows / Linux
What did you do?
In my project, I had until now only SQL migrations files and everything was running correctly. Now I have also a Java migration file.
What did you expect to see?
I'm expecting that the whole migration runs successfully (ie. migration performed using both SQL and Java migration files)
What did you see instead?
In eclipse, it's running well, but once released, the applications fails to start, with exception "Unable to resolve Jdbc Java migrations in location: classpath:foo/bar"
Root exception is a null pointer in ClassUtils#getLocationOnDisk line 117 and the reason is that a ProtectionDomain is supposed to always have a CodeSource having itself a not null location. In my case, the CodeSource has a null location because I'm using a custom class loader which defines classes by calling URLClassLoader#defineClass(String name, byte b, int off, int len) (J2SE standard). In that case, a default ProtectionDomain is used, in which the CodeSource has a null location (see ClassLoader#defaultDomain).
Flyway should not assume that a CodeSource always has a non null location because Java doesn't make this assumption.
The text was updated successfully, but these errors were encountered: