diff --git a/jetty-deploy/src/main/config/etc/jetty-deploy.xml b/jetty-deploy/src/main/config/etc/jetty-deploy.xml
index 199eeb5d655..ebbec509329 100644
--- a/jetty-deploy/src/main/config/etc/jetty-deploy.xml
+++ b/jetty-deploy/src/main/config/etc/jetty-deploy.xml
@@ -24,6 +24,24 @@
org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern
.*/jsp-api-[^/]*\.jar$|.*/jsp-[^/]*\.jar$
+
+
+
+
+
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/bindings/DebugBinding.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/bindings/DebugBinding.java
new file mode 100644
index 00000000000..69d45d084f1
--- /dev/null
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/bindings/DebugBinding.java
@@ -0,0 +1,47 @@
+// ========================================================================
+// Copyright (c) Webtide LLC
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.apache.org/licenses/LICENSE-2.0.txt
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+package org.eclipse.jetty.deploy.bindings;
+
+import org.eclipse.jetty.deploy.App;
+import org.eclipse.jetty.deploy.AppLifeCycle;
+import org.eclipse.jetty.deploy.graph.Node;
+import org.eclipse.jetty.server.handler.ContextHandler;
+import org.eclipse.jetty.util.log.Log;
+
+public class DebugBinding implements AppLifeCycle.Binding
+{
+ final String[] _targets;
+
+ public DebugBinding(String target)
+ {
+ _targets=new String[]{target};
+ }
+
+ public DebugBinding(final String... targets)
+ {
+ _targets=targets;
+ }
+
+ public String[] getBindingTargets()
+ {
+ return _targets;
+ }
+
+ public void processBinding(Node node, App app) throws Exception
+ {
+ Log.info("processBinding {} {}",node,app.getContextHandler());
+ }
+}
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
index a0784a560ea..8d396d68ac5 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
@@ -77,15 +77,7 @@ public class Main
public static void main(String[] args)
{
Main main = new Main();
- try
- {
- main.parseCommandLine(args);
- }
- catch (Throwable t)
- {
- t.printStackTrace(System.err);
- System.exit(ERR_UNKNOWN);
- }
+ main.parseCommandLine(args);
}
public void parseCommandLine(String[] args)
@@ -186,7 +178,7 @@ public class Main
// Output about error is lost in majority of cases.
System.err.println("Unable to create: " + startLog.getAbsolutePath());
// Toss a unique exit code indicating this failure.
- System.exit(ERR_LOGGING);
+ usageExit(ERR_LOGGING);
}
if (!startLog.canWrite())
@@ -194,7 +186,7 @@ public class Main
// Output about error is lost in majority of cases.
System.err.println("Unable to write to: " + startLog.getAbsolutePath());
// Toss a unique exit code indicating this failure.
- System.exit(ERR_LOGGING);
+ usageExit(ERR_LOGGING);
}
PrintStream logger = new PrintStream(new FileOutputStream(startLog,false));
System.setOut(logger);
@@ -272,7 +264,7 @@ public class Main
if (xmls.contains(arg))
{
System.out.println("WARN: Argument '"+arg+"' specified multiple times. Check start.ini?");
- System.out.println("Use java -jar start.jar --help for usage information.");
+ System.out.println("Use \"java -jar start.jar --help\" for more information.");
}
xmls.add(arg);
}
@@ -281,9 +273,7 @@ public class Main
}
catch (Throwable t)
{
- t.printStackTrace(System.err);
- System.out.println("Use java -jar start.jar --help for usage information.");
- System.exit(ERR_UNKNOWN);
+ usageExit(t,ERR_UNKNOWN);
}
}
@@ -294,7 +284,7 @@ public class Main
{
String jettyHome=System.getProperty("jetty.home");
File startIniFile = ini==null?((jettyHome!=null)? new File(jettyHome,"start.ini"):new File("start.ini")):new File(ini);
- if (!startIniFile.exists() || !startIniFile.canRead())
+ if (!startIniFile.exists())
{
if (ini != null)
{
@@ -326,8 +316,7 @@ public class Main
}
catch (IOException e)
{
- e.printStackTrace(System.err);
- System.exit(ERR_UNKNOWN);
+ usageExit(e,ERR_UNKNOWN);
}
finally
{
@@ -345,9 +334,8 @@ public class Main
if (usageStream == null)
{
- System.err.println("Usage: java -jar start.jar [options] [properties] [configs]");
System.err.println("ERROR: detailed usage resource unavailable");
- System.exit(EXIT_USAGE);
+ usageExit(EXIT_USAGE);
}
BufferedReader buf = null;
@@ -438,7 +426,7 @@ public class Main
}
catch (IOException e)
{
- e.printStackTrace(System.err);
+ usageExit(e,EXIT_USAGE);
}
finally
{
@@ -474,9 +462,7 @@ public class Main
if (invoked_class == null)
{
- System.err.println("Usage: java -jar start.jar [options] [properties] [configs]");
- System.err.println(" java -jar start.jar --help # for more information");
- System.exit(ERR_INVOKE_MAIN);
+ usageExit(ERR_INVOKE_MAIN);
return;
}
}
@@ -633,8 +619,7 @@ public class Main
}
catch (Exception e)
{
- e.printStackTrace(System.err);
- System.exit(ERR_INVOKE_MAIN);
+ usageExit(e,ERR_INVOKE_MAIN);
}
}
@@ -950,8 +935,7 @@ public class Main
}
catch (Exception e)
{
- e.printStackTrace(System.err);
- System.exit(ERR_SECURITY);
+ usageExit(e,ERR_SECURITY);
}
}
@@ -985,8 +969,7 @@ public class Main
}
catch (Exception e)
{
- e.printStackTrace(System.err);
- System.exit(ERR_UNKNOWN);
+ usageExit(e,ERR_UNKNOWN);
}
finally
{
@@ -1040,8 +1023,7 @@ public class Main
}
catch (Exception e)
{
- e.printStackTrace();
- System.exit(ERR_UNKNOWN);
+ usageExit(e,ERR_UNKNOWN);
return null; // never executed (just here to satisfy javac compiler)
}
finally
@@ -1115,13 +1097,28 @@ public class Main
}
catch (ConnectException e)
{
- System.err.println("ERROR: Not running!");
- System.exit(ERR_NOT_STOPPED);
+ usageExit(e,ERR_NOT_STOPPED);
}
catch (Exception e)
{
- e.printStackTrace(System.err);
- System.exit(ERR_UNKNOWN);
+ usageExit(e,ERR_UNKNOWN);
}
}
+
+
+ static void usageExit(Throwable t, int exit)
+ {
+ t.printStackTrace(System.err);
+ System.err.println();
+ System.err.println("Usage: java -jar start.jar [options] [properties] [configs]");
+ System.err.println(" java -jar start.jar --help # for more information");
+ System.exit(exit);
+ }
+ static void usageExit(int exit)
+ {
+ System.err.println();
+ System.err.println("Usage: java -jar start.jar [options] [properties] [configs]");
+ System.err.println(" java -jar start.jar --help # for more information");
+ System.exit(exit);
+ }
}
diff --git a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java
index 054c257fe12..f678a5a330e 100644
--- a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java
+++ b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java
@@ -38,6 +38,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jetty.util.LazyList;
import org.eclipse.jetty.util.Loader;
@@ -985,9 +986,11 @@ public class XmlConfiguration
* @param args array of property and xml configuration filenames or {@link Resource}s.
*/
@SuppressWarnings( "unchecked" )
- public static void main( final String[] args )
+ public static void main( final String[] args ) throws Exception
{
+ final AtomicReference exception = new AtomicReference();
+
AccessController.doPrivileged( new PrivilegedAction()
{
public Object run()
@@ -1062,14 +1065,30 @@ public class XmlConfiguration
catch (AccessControlException ace)
{
ace.printStackTrace(System.err);
+ exception.set(ace);
}
catch ( Exception e )
{
- Log.warn( Log.EXCEPTION, e );
+ Log.debug( Log.EXCEPTION, e );
+ exception.set(e);
}
return null;
}
} );
+
+ Throwable th=exception.get();
+ if (th!=null)
+ {
+ if (th instanceof Exception)
+ throw (Exception)th;
+ else if (th instanceof Error)
+ throw (Error)th;
+ else if (th instanceof RuntimeException)
+ throw (RuntimeException)th;
+ else if (th instanceof ThreadDeath)
+ throw (ThreadDeath)th;
+ throw new Error(th);
+ }
}
}