Remove servlet-api from WAR/lib
It is wrong to include the servlet API in a WAR's WEB-INF/lib directory. This confuses some servlet containers who refuse to load the Gerrit WAR. Instead package the Jetty runtime and the servlet API in a new WEB-INF/pgm-lib directory. Change-Id: Ic5fe14c735e781b2d78d2fa8d0d403a08b7ee21f
This commit is contained in:
@@ -206,27 +206,10 @@ public final class GerritLauncher {
|
||||
final ZipEntry ze = e.nextElement();
|
||||
if (ze.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ze.getName().startsWith("WEB-INF/lib/")) {
|
||||
String name = ze.getName().substring("WEB-INF/lib/".length());
|
||||
final File tmp = createTempFile(safeName(ze), ".jar");
|
||||
final FileOutputStream out = new FileOutputStream(tmp);
|
||||
try {
|
||||
final InputStream in = zf.getInputStream(ze);
|
||||
try {
|
||||
final byte[] buf = new byte[4096];
|
||||
int n;
|
||||
while ((n = in.read(buf, 0, buf.length)) > 0) {
|
||||
out.write(buf, 0, n);
|
||||
}
|
||||
} finally {
|
||||
in.close();
|
||||
}
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
jars.put(name, tmp.toURI().toURL());
|
||||
} else if (ze.getName().startsWith("WEB-INF/lib/")) {
|
||||
extractJar(zf, ze, jars);
|
||||
} else if (ze.getName().startsWith("WEB-INF/pgm-lib/")) {
|
||||
extractJar(zf, ze, jars);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
@@ -261,6 +244,31 @@ public final class GerritLauncher {
|
||||
parent);
|
||||
}
|
||||
|
||||
private static void extractJar(ZipFile zf, ZipEntry ze,
|
||||
SortedMap<String, URL> jars) throws IOException {
|
||||
File tmp = createTempFile(safeName(ze), ".jar");
|
||||
FileOutputStream out = new FileOutputStream(tmp);
|
||||
try {
|
||||
InputStream in = zf.getInputStream(ze);
|
||||
try {
|
||||
byte[] buf = new byte[4096];
|
||||
int n;
|
||||
while ((n = in.read(buf, 0, buf.length)) > 0) {
|
||||
out.write(buf, 0, n);
|
||||
}
|
||||
} finally {
|
||||
in.close();
|
||||
}
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
|
||||
String name = ze.getName();
|
||||
jars.put(
|
||||
name.substring(name.lastIndexOf('/'), name.length()),
|
||||
tmp.toURI().toURL());
|
||||
}
|
||||
|
||||
private static void move(SortedMap<String, URL> jars,
|
||||
String prefix,
|
||||
List<URL> extapi) {
|
||||
|
Reference in New Issue
Block a user