Move setting of InstanceManager to WebAppConfiguration to avoid race

Fix up LICENSES.txt
Build.xml cleanup
Debian:
- Add support for with-libtomcat8-java but not with-libjetty9-java for wheezy/jessie
- Fix wheezy/precise/trusty build files to use tomcat8 but not jetty9 packages
- Remove build dependency on ant-optional, not required
- Remove some remaining eclipse-ecj dependencies
- Add short README files for wheezy and jessie
This commit is contained in:
zzz
2017-03-04 14:24:48 +00:00
parent ec6c24429a
commit f38ee48ca3
22 changed files with 155 additions and 116 deletions

View File

@ -40,7 +40,6 @@ import net.i2p.util.SecureDirectory;
import net.i2p.util.I2PSSLSocketFactory;
import net.i2p.util.SystemVersion;
import org.apache.tomcat.SimpleInstanceManager;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
@ -648,7 +647,9 @@ public class RouterConsoleRunner implements RouterApp {
} catch (ClassNotFoundException cnfe) {
System.err.println("Warning: JettyJasperInitializer not found");
}
initialize(_context, (WebAppContext)(rootWebApp.getHandler()));
WebAppContext wac = (WebAppContext)(rootWebApp.getHandler());
initialize(_context, wac);
WebAppStarter.setWebAppConfiguration(wac);
chColl.addHandler(rootWebApp);
} catch (Exception ioe) {
@ -662,10 +663,6 @@ public class RouterConsoleRunner implements RouterApp {
try {
// start does a mapContexts()
_server.start();
// can't do this before start
// http://stackoverflow.com/questions/17529936/issues-while-using-jetty-embedded-to-handle-jsp-jasperexception-unable-to-com
// https://github.com/jetty-project/embedded-jetty-jsp/blob/master/src/main/java/org/eclipse/jetty/demo/Main.java
rootServletHandler.getServletContext().setAttribute("org.apache.tomcat.InstanceManager", new SimpleInstanceManager());
} catch (Throwable me) {
// NoClassFoundDefError from a webapp is a throwable, not an exception
System.err.println("Error starting the Router Console server: " + me);

View File

@ -15,6 +15,7 @@ import java.util.StringTokenizer;
import net.i2p.I2PAppContext;
import org.apache.tomcat.SimpleInstanceManager;
import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.WebAppClassLoader;
import org.eclipse.jetty.webapp.WebAppContext;
@ -191,6 +192,10 @@ public class WebAppConfiguration implements Configuration {
/** @since Jetty 7 */
public void configure(WebAppContext context) throws Exception {
configureClassPath(context);
// do we just need one, in the ContextHandlerCollection, or one for each?
// http://stackoverflow.com/questions/17529936/issues-while-using-jetty-embedded-to-handle-jsp-jasperexception-unable-to-com
// https://github.com/jetty-project/embedded-jetty-jsp/blob/master/src/main/java/org/eclipse/jetty/demo/Main.java
context.getServletContext().setAttribute("org.apache.tomcat.InstanceManager", new SimpleInstanceManager());
}
/** @since Jetty 7 */

View File

@ -10,7 +10,6 @@ import net.i2p.router.RouterContext;
import net.i2p.util.FileUtil;
import net.i2p.util.SecureDirectory;
import org.apache.tomcat.SimpleInstanceManager;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandler;
@ -64,11 +63,6 @@ public class WebAppStarter {
// and the caller will know it failed
wac.setThrowUnavailableOnStartupException(true);
wac.start();
// can't do this before start
// do we just need one, in the ContextHandlerCollection, or one for each?
// http://stackoverflow.com/questions/17529936/issues-while-using-jetty-embedded-to-handle-jsp-jasperexception-unable-to-com
// https://github.com/jetty-project/embedded-jetty-jsp/blob/master/src/main/java/org/eclipse/jetty/demo/Main.java
wac.getServletContext().setAttribute("org.apache.tomcat.InstanceManager", new SimpleInstanceManager());
}
/**
@ -115,7 +109,16 @@ public class WebAppStarter {
// this does the passwords...
RouterConsoleRunner.initialize(ctx, wac);
setWebAppConfiguration(wac);
server.addHandler(wac);
server.mapContexts();
return wac;
}
/**
* @since Jetty 9
*/
static void setWebAppConfiguration(WebAppContext wac) {
// see WebAppConfiguration for info
String[] classNames = wac.getConfigurationClasses();
// In Jetty 9, it doesn't set the defaults if we've already added one, but the
@ -130,9 +133,6 @@ public class WebAppStarter {
newClassNames[j] = classNames[j];
newClassNames[classNames.length] = WebAppConfiguration.class.getName();
wac.setConfigurationClasses(newClassNames);
server.addHandler(wac);
server.mapContexts();
return wac;
}
/**