Hi guys,
I created a modifies SpringLiquibase instance with the following modifications, because in weblogic the application can't find the selected classes in the zip file.
SpringResourceOpener:
isPrefixPresent method: added
- || file.matches("^.+:.+")
modified ClassLoaderResourceAccessor list method:
The original contains these code:
- if (!fileUrls.hasMoreElements() && (path.startsWith("jar:") || path.startsWith("file:"))) {
fileUrls = new Vector<URL>(Arrays.asList(new URL(path))).elements();
}
- if (!fileUrls.hasMoreElements() && (path.startsWith("jar:") || path.startsWith("file:")) || path.startsWith("zip:")) {
fileUrls = new Vector<>(Arrays.asList(new URL(path))).elements();
}
(Suprise: in the while cycle the application watch the zip: prefix, but it's not added like a jar ;))
Still in the list method the jar file processing maybe wrong (especially in weblogic):
- When the path start jar, wsjar or zip liquibase try to find the files, but it's wrong. Here is the original code
- JarFile zipfile = new JarFile(zipFilePath, false);
try {
Enumeration<JarEntry> entries = zipfile.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
if (entry.getName().startsWith(path)) {
example:
path => zip:C:/Oracle/Oracle_Home/user_projects/domains/test/servers/AdminServer/tmp/_WL_user/Gradle___hu_tsystems_molcc___molocc-backend-ear_ear_v20171124-1514/cw1bp9/war/WEB-INF/lib/hu.tsystems.molcc-molocc-interface-1.4.0-SNAPSHOT.jar!/META-INF/liquibase/
entry.getName() => META-INF/liquibase/
My solution:
- JarFile zipfile = new JarFile(zipFilePath, false);
String internalPath = zipAndFile[1];
try {
Enumeration<JarEntry> entries = zipfile.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
if (("/"+entry.getName()).startsWith(internalPath)) {
Thanks