Build: Fix hang with Tomcat 8.5.33+ (ticket #2307)

This commit is contained in:
zzz
2018-09-16 11:29:03 +00:00
parent 4ead982831
commit 6b53a4fac4
4 changed files with 67 additions and 5 deletions

View File

@@ -305,8 +305,8 @@
<delete file="../jsp/web-out.xml" />
<mkdir dir="../jsp/WEB-INF/" />
<mkdir dir="../jsp/WEB-INF/classes" />
<!-- there are various jspc ant tasks, but they all seem a bit flakey -->
<java classname="org.apache.jasper.JspC" fork="true" failonerror="true">
<!-- See apps/routerconsole/java/build.xml for important JspC build documentation -->
<java classname="net.i2p.servlet.util.JspC" fork="true" failonerror="true">
<classpath>
<pathelement location="../../jetty/jettylib/jasper-runtime.jar" />
<pathelement location="../../jetty/jettylib/javax.servlet.jar" />

View File

@@ -0,0 +1,34 @@
package net.i2p.servlet.util;
import java.lang.reflect.Method;
/**
* Simply call org.apache.jasper.JspC, then exit.
*
* As of Tomcat 8.5.33, forking their JspC won't complete,
* because the JspC compilation is now threaded and the thread pool workers aren't daemons.
* May be fixed in a future release, maybe not, but we don't know what version distros may have.
*
* https://tomcat.apache.org/tomcat-8.5-doc/changelog.html
* https://bz.apache.org/bugzilla/show_bug.cgi?id=53492
*
* We could set fork=false in build.xml, but then the paths are all wrong.
* Only for use in build scripts, obviously not a public API.
* See apps/routerconsole/java/build.xml for more information.
*
* @since 0.9.37
*/
public class JspC {
public static void main(String args[]) {
try {
String cls = "org.apache.jasper.JspC";
Class<?> c = Class.forName(cls, true, ClassLoader.getSystemClassLoader());
Method main = c.getMethod("main", String[].class);
main.invoke(null, (Object) args);
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
}

View File

@@ -353,7 +353,13 @@
<mkdir dir="../jsp/WEB-INF/" />
<mkdir dir="../jsp/WEB-INF/classes" />
<!-- there are various jspc ant tasks, but they all seem a bit flakey -->
<!-- There are various jspc ant tasks, but they all seem a bit flakey.
Warning - jspC will fail on unknown options,
check oldest libtomcat8-java distro package version we use.
Jessie has 8.0.14; xenial has 8.0.32; we bundle for precise/trusty.
Add below to get supported options:
<arg value="-help" />
-->
<!--
** Usage: jspc <options> <jsp files>
** where jsp files is
@@ -381,8 +387,28 @@
** -classpath <path> Overrides java.class.path system property
** -xpoweredBy Add X-Powered-By response header
** -trimSpaces Trim spaces in template text between actions, directives
** Following as of ?.?.??:
** -javaEncoding <enc> Set the encoding charset for Java classes (default UTF-8)
** -source <version> Set the -source argument to the compiler (default 1.7)
** -target <version> Set the -target argument to the compiler (default 1.7)
** Following as of 8.5.33:
** -threadCount <count> Number of threads to use for compilation.
** (default one per core)
** ("2.0C" means two threads per core)
-->
<java classname="org.apache.jasper.JspC" fork="true" failonerror="true">
<!--
** Simply call org.apache.jasper.JspC, then exit.
**
** As of Tomcat 8.5.33, forking their JspC won't complete,
** because the JspC compilation is now threaded and the thread pool workers aren't daemons.
** May be fixed in a future release, maybe not, but we don't know what version distros may have.
**
** https://tomcat.apache.org/tomcat-8.5-doc/changelog.html
** https://bz.apache.org/bugzilla/show_bug.cgi?id=53492
**
** We could set fork=false in build.xml, but then the paths are all wrong.
-->
<java classname="net.i2p.servlet.util.JspC" fork="true" failonerror="true">
<!-- this prevents tomcat from complaining in debian builds -->
<jvmarg value="-Dtomcat.util.scan.StandardJarScanFilter.jarsToSkip=commons-collections.jar,junit.jar,junit4.jar" />
<classpath>

View File

@@ -30,6 +30,7 @@
<pathelement location="lib/standard.jar" />
<pathelement location="${lib}/jasper-runtime.jar" />
<pathelement location="${lib}/jetty-util.jar" />
<pathelement location="${lib}/jetty-i2p.jar" />
<pathelement location="${ant.home}/lib/ant.jar" />
<pathelement location="../../../core/java/build/i2p.jar" />
<pathelement location="../../addressbook/dist/addressbook.jar" />
@@ -69,7 +70,8 @@
<delete file="WEB-INF/web-out.xml" />
<mkdir dir="${tmp}" />
<echo message="Ignore any warning about /WEB-INF/web.xml not found" />
<java classname="org.apache.jasper.JspC" fork="true" classpathref="cp" failonerror="true">
<!-- See apps/routerconsole/java/build.xml for important JspC build documentation -->
<java classname="net.i2p.servlet.util.JspC" fork="true" classpathref="cp" failonerror="true">
<arg value="-d" />
<arg value="${tmp}" />
<arg value="-v" />