diff --git a/VERSION.txt b/VERSION.txt index 57181870f5a..351ef10153a 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -12,6 +12,7 @@ jetty-7.1-SNAPSHOT + 309466 Removed synchronization from StdErrLog + 309765 Added JSP module + 310051 _configurationClasses now defaults to null in WebAppContext + + 310094 Improved start.jar usage and config files + JETTY-903 Stop both caches + JETTY-1200 SSL NIO Endpoint wraps non NIO buffers + JETTY-1202 Use platform default algorithm for SecureRandom diff --git a/jetty-deploy/pom.xml b/jetty-deploy/pom.xml index a32f1152e91..83491d7ddaa 100644 --- a/jetty-deploy/pom.xml +++ b/jetty-deploy/pom.xml @@ -26,6 +26,23 @@ + + org.apache.maven.plugins + maven-assembly-plugin + + + package + + single + + + + config.xml + + + + + + + + + + + + + + + + + + + + + + + + + org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern + .*/jsp-api-[^/]*\.jar$|.*/jsp-[^/]*\.jar$ + + + + + + /contexts + 5 + + + + + + + + /webapps + /etc/webdefault.xml + 5 + /contexts + + + + + + + diff --git a/jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml b/jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml index 841944926dd..07cf8d28890 100644 --- a/jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml +++ b/jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml @@ -15,7 +15,7 @@ - /contexts + /contexts 1 @@ -28,9 +28,9 @@ - /webapps + /webapps 1 - /contexts + /contexts diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml index 8154e4eb2d1..04e594cbf93 100644 --- a/jetty-distribution/pom.xml +++ b/jetty-distribution/pom.xml @@ -143,6 +143,16 @@ ** ${assembly.directory} + + org.eclipse.jetty + jetty-deploy + ${project.version} + config + jar + true + ** + ${assembly.directory} + org.eclipse.jetty jetty-plus diff --git a/jetty-distribution/src/main/resources/start.ini b/jetty-distribution/src/main/resources/start.ini index 28c64573b2d..3663603cfda 100644 --- a/jetty-distribution/src/main/resources/start.ini +++ b/jetty-distribution/src/main/resources/start.ini @@ -1,10 +1,13 @@ #=========================================================== # Jetty start.jar arguments -#----------------------------------------------------------- # Each line of this file is prepended to the command line # arguments # of a call to: # java -jar start.jar [arg...] -# +#=========================================================== + + + +#=========================================================== # If the arguements in this file include JVM arguments # (eg -Xmx512m) or JVM System properties (eg com.sun.???), # then these will not take affect unless the --exec @@ -12,20 +15,46 @@ # is executed like: # eval $(java -jar start.jar --dry-run) # -#=========================================================== - -OPTIONS=Server,jsp,jmx,resources,websocket,ext - -#=========================================================== -# The following is an example of the ini args to run the -# server with a heap size, JMX remote enabled, JMX mbeans -# and ssl +# Below are some recommended options for Sun's JRE #----------------------------------------------------------- # --exec -# -Xmx512m # -Dcom.sun.management.jmxremote -# OPTIONS=Server,jmx,resources -# etc/jetty-jmx.xml -# etc/jetty.xml -# etc/jetty-ssl.xml +# -Xmx2000m +# -Xmn512m +# -verbose:gc +# -XX:+PrintGCDateStamps +# -XX:+PrintGCTimeStamps +# -XX:+PrintGCDetails +# -XX:+PrintTenuringDistribution +# -XX:+PrintCommandLineFlags +# -XX:+DisableExplicitGC +# -XX:+UseConcMarkSweepGC +# -XX:ParallelCMSThreads=2 +# -XX:+CMSClassUnloadingEnabled +# -XX:+UseCMSCompactAtFullCollection +# -XX:CMSInitiatingOccupancyFraction=80 +#----------------------------------------------------------- + + +#=========================================================== +# Start classpath OPTIONS. +# These control what classes are on the classpath +# for a full listing do +# java -jar start.jar --list-options +#----------------------------------------------------------- +OPTIONS=Server,jsp,jmx,resources,websocket,ext +#----------------------------------------------------------- + + +#=========================================================== +# Configuration files. +# For a full list of available configuration files do +# java -jar start.jar --help +#----------------------------------------------------------- +#etc/jetty-jmx.xml +etc/jetty.xml +# etc/jetty-ssl.xml +# etc/jetty-requestlog.xml +etc/jetty-deploy.xml +etc/jetty-testrealm.xml #=========================================================== diff --git a/jetty-plus/src/main/config/etc/jetty-plus.xml b/jetty-plus/src/main/config/etc/jetty-plus.xml index 027a1dc7b49..06bbcd2fcf0 100644 --- a/jetty-plus/src/main/config/etc/jetty-plus.xml +++ b/jetty-plus/src/main/config/etc/jetty-plus.xml @@ -63,10 +63,10 @@ - /webapps-plus + /webapps-plus /etc/webdefault.xml 5 - /contexts + /contexts false true diff --git a/jetty-server/src/main/config/etc/jetty-requestlog.xml b/jetty-server/src/main/config/etc/jetty-requestlog.xml new file mode 100644 index 00000000000..4ab4f677053 --- /dev/null +++ b/jetty-server/src/main/config/etc/jetty-requestlog.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + /logs/yyyy_mm_dd.request.log + yyyy_MM_dd + 90 + true + false + false + GMT + + + + + + + + diff --git a/jetty-server/src/main/config/etc/jetty.xml b/jetty-server/src/main/config/etc/jetty.xml index 323d6106565..fcfd31857cc 100644 --- a/jetty-server/src/main/config/etc/jetty.xml +++ b/jetty-server/src/main/config/etc/jetty.xml @@ -5,8 +5,13 @@ - + + + + + + @@ -23,8 +28,6 @@ - - @@ -44,26 +47,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -77,95 +60,11 @@ - - - - - - - - - - - - - - - - - - org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern - .*/jsp-api-[^/]*\.jar$|.*/jsp-[^/]*\.jar$ - - - - - - /contexts - 5 - - - - - - - - /webapps - /etc/webdefault.xml - 5 - /contexts - - - - - - - - - - - - - - - - - - Test Realm - /etc/realm.properties - 0 - - - - - - - - - - - - - - - /logs/yyyy_mm_dd.request.log - yyyy_MM_dd - 90 - true - false - false - GMT - - - - 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 435b0084179..f150f2cdabb 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 @@ -63,7 +63,7 @@ public class Main private boolean _fromDaemon = false; private final Config _config = new Config(); private Set _sysProps = new HashSet(); - private List _xArgs = new ArrayList(); + private List _jvmArgs = new ArrayList(); private String _jettyHome; @@ -86,16 +86,35 @@ public class Main { List arguments = new ArrayList(); - arguments.addAll(loadStartIni()); // Add Arguments from start.ini (if it exists) - if (args.length>0) - arguments.addAll(Arrays.asList(args)); // Add Arguments on Command Line + // do we have any non option args + boolean has_args=false; + for (String arg : args) + has_args|=!arg.startsWith("-"); + + // if no non-option args, add the start.ini + if (!has_args) + arguments.addAll(loadStartIni()); // Add Arguments from start.ini (if it exists) + + // add the command line args + for (String arg : args) + { + if ("%start.ini".equals(arg)) + { + arguments.addAll(loadStartIni()); + continue; + } + + arguments.add(arg); + } // The XML Configuration Files to initialize with List xmls = new ArrayList(); + // Process the arguments for (String arg : arguments) { - if ("--help".equals(arg)) + + if ("--help".equals(arg) || "-?".equals(arg)) { _showUsage = true; continue; @@ -148,12 +167,6 @@ public class Main _secure = true; continue; } - - if (arg.startsWith("-X")) - { - _xArgs.add(arg); - continue; - } if (arg.startsWith("-D")) { @@ -173,15 +186,28 @@ public class Main continue; } + if (arg.startsWith("-")) + { + _jvmArgs.add(arg); + continue; + } + // Is this a Property? - else if (arg.indexOf('=') >= 0) + if (arg.indexOf('=') >= 0) { String[] assign = arg.split("=",2); switch(assign.length) { case 2: - this._config.setProperty(assign[0],assign[1]); + if ("OPTIONS".equals(assign[0])) + { + String opts[] = assign[1].split(","); + for (String opt : opts) + _config.addActiveOption(opt); + } + else + this._config.setProperty(assign[0],assign[1]); break; case 1: this._config.setProperty(assign[0],null); @@ -189,21 +215,13 @@ public class Main default: break; } + continue; } // Anything else is considered an XML file. xmls.add(arg); } - - // Special case for OPTIONS property - String options = _config.getProperty("OPTIONS"); - if (options!=null) - { - String ids[] = options.split(","); - for (String id : ids) - _config.addActiveOption(id); - } start(xmls); } @@ -278,61 +296,81 @@ public class Main while ((line = buf.readLine()) != null) { - if (line.startsWith("@OPTIONS@")) + if (line.endsWith("@") && line.indexOf('@')!=line.lastIndexOf('@')) { - List sortedOptions = new ArrayList(); - sortedOptions.addAll(_config.getSectionIds()); - Collections.sort(sortedOptions); + String indent=line.substring(0,line.indexOf("@")); + String info=line.substring(line.indexOf('@'),line.lastIndexOf('@')); - System.err.println(" Available OPTIONS: "); + if (info.equals("@OPTIONS")) + { + List sortedOptions = new ArrayList(); + sortedOptions.addAll(_config.getSectionIds()); + Collections.sort(sortedOptions); - for (String option : sortedOptions) - { - System.err.println(" [" + option + "]"); - } - } - else if (line.startsWith("@CONFIGS@")) - { - System.err.println(" Configurations Available in ${jetty.home}/etc/: "); - File etc = new File(System.getProperty("jetty.home","."),"etc"); - if (!etc.exists()) - { - System.err.println(" Unable to find " + etc); - continue; - } - - if (!etc.isDirectory()) - { - System.err.println(" Unable list dir " + etc); - continue; - } - - File configs[] = etc.listFiles(new FileFilter() - { - public boolean accept(File path) + for (String option : sortedOptions) { - if (!path.isFile()) - { - return false; - } - - String name = path.getName().toLowerCase(); - return (name.startsWith("jetty") && name.endsWith(".xml")); + if ("*".equals(option) || option.trim().length()==0) + continue; + System.out.print(indent); + System.out.println(option); } - }); - - List configFiles = new ArrayList(); - configFiles.addAll(Arrays.asList(configs)); - Collections.sort(configFiles); - - for (File configFile : configFiles) + } + else if (info.equals("@CONFIGS")) { - System.err.println(" etc/" + configFile.getName()); + File etc = new File(System.getProperty("jetty.home","."),"etc"); + if (!etc.exists() || !etc.isDirectory()) + { + System.out.print(indent); + System.out.println("Unable to find/list " + etc); + continue; + } + + File configs[] = etc.listFiles(new FileFilter() + { + public boolean accept(File path) + { + if (!path.isFile()) + { + return false; + } + + String name = path.getName().toLowerCase(); + return (name.startsWith("jetty") && name.endsWith(".xml")); + } + }); + + List configFiles = new ArrayList(); + configFiles.addAll(Arrays.asList(configs)); + Collections.sort(configFiles); + + for (File configFile : configFiles) + { + System.out.print(indent); + System.out.print("etc/"); + System.out.println(configFile.getName()); + } + } + else if (info.equals("@STARTINI")) + { + List ini = loadStartIni(); + if (ini!=null && ini.size()>0) + { + for (String a : ini) + { + System.out.print(indent); + System.out.println(a); + } + } + else + { + System.out.print(indent); + System.out.println("none"); + } } } else { - System.err.println(line); + System.out.println(line); } } } @@ -380,7 +418,8 @@ public class Main if (invoked_class == null) { - usage(); + System.err.println("Usage: java -jar start.jar [options] [properties] [configs]"); + System.err.println(" java -jar start.jar --help # for more information"); return; } } @@ -516,7 +555,7 @@ public class Main return; } - if (_xArgs.size()>0 || _sysProps.size()>0) + if (_jvmArgs.size()>0 || _sysProps.size()>0) System.err.println("WARNING: System properties and/or JVM args set. Consider using --dry-run or --exec"); // Set current context class loader to what is selected. @@ -609,18 +648,18 @@ public class Main { StringBuilder cmd = new StringBuilder(); cmd.append(findJavaBin()); - for (String x:_xArgs) + for (String x:_jvmArgs) cmd.append(' ').append(x); cmd.append(" -Djetty.home=").append(_jettyHome); for (String p:_sysProps) { - cmd.append(" -D").append(p); + cmd.append(" -D").append(p); String v=System.getProperty(p); - if (v!=null) + if (v!=null && v.length()>0) cmd.append('=').append(v); } - cmd.append(" -cp ").append(classpath.toString()); - cmd.append(' ').append(_config.getMainClassname()); + cmd.append(" -cp ").append(classpath.toString()); + cmd.append(" ").append(_config.getMainClassname()); for (String xml : xmls) { cmd.append(' ').append(xml); diff --git a/jetty-start/src/main/resources/org/eclipse/jetty/start/start.config b/jetty-start/src/main/resources/org/eclipse/jetty/start/start.config index 0c1dc119db0..2761897e7a1 100644 --- a/jetty-start/src/main/resources/org/eclipse/jetty/start/start.config +++ b/jetty-start/src/main/resources/org/eclipse/jetty/start/start.config @@ -139,13 +139,17 @@ $(jetty.home)/lib/setuid/** $(jetty.home)/lib/jetty-policy-$(version).jar ! available org.eclipse.jetty.policy.JettyPolicy $(jetty.home)/lib/policy/jetty.policy -[All,client] +[All,Client,client] $(jetty.home)/lib/jetty-http-$(version).jar ! available org.eclipse.jetty.http.HttpParser $(jetty.home)/lib/jetty-client-$(version).jar ! available org.eclipse.jetty.client.HttpClient +[Client] +$(jetty.home)/lib/jetty-http-$(version).jar ! available org.eclipse.jetty.http.HttpParser + [All,websocket] $(jetty.home)/lib/jetty-websocket-$(version).jar ! available org.eclipse.jetty.websocket.WebSocket - + + # Add ext if it exists [Server,All,default,ext] $(jetty.home)/lib/ext/** diff --git a/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt b/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt index 18a0e3b495f..7383c0112a4 100644 --- a/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt +++ b/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt @@ -1,58 +1,60 @@ -Usage: java -jar start.jar [options] [properties] [configs] +Usage: java -jar start.jar [options...] [properties...] [configs...] The start.jar builds a classpath and executes a main java class with a classloader built from that classpath. By default the start.jar mechanism is configured to start the jetty server, but it can be configured to start any java main class. -Common Options: +Command Line Options: --help This help / usage information. - --version Print the version information for Jetty, then exit. - --stop Stop the running Jetty instance. - -Advanced Options: - - --list-options List available options, then exit. - (see OPTION property in section below) + + --version Print the version information for Jetty and + dependent jars, then exit. + --list-options List the details of each classpath OPTION + --dry-run Print the command line that the start.jar generates, then exit. This may be used to generate command lines when the start.ini includes -X or -D arguments. - On unix, the resulting command line can be run with - eval $(java -jar start.jar --dry-run) - This is more efficient than the --exec option, which - creates a second JVM instance --exec Run the generated command line (see --dry-run) in a sub processes. This can be used when start.ini contains -X or -D arguments, but creates an extra JVM instance. + --secure Enable Security: * JVM Security Manager * Security Policies * Secure Logging * Audit Logging - - If the file start.ini exists in the working directory, then it's each line - of it's contents is prepended to the as an argument to the command line. + + --stop Stop the running Jetty instance. + System Properties: These are set with a command line like "java -Dname=value ..." and are accessible via the java.lang.System#getProperty(String) API. Some key system properties are: + org.eclipse.jetty.util.log.class=[class] A Low Level Jetty Logger Implementation to use (default: org.eclipse.jetty.util.log.Slf4jLog) + org.eclipse.jetty.util.log.DEBUG=[boolean] Debug logging for the stderr and javautil Loggers. Slf4j and other loggers must be separately configured for debug. (default: false) + org.eclipse.jetty.util.log.IGNORED=[boolean] Ignored exceptions are logged, independent of DEBUG settings (default: false) -Start Properties: + com.sun.management.jmxremote + Enable remote JMX management in Sun JVMS. + + +Properties: These are set with a command line like "java -jar start.jar name=value" and only affect the start mechanism. Some of these are defined in the default start.config and will not be available if another configuration @@ -61,29 +63,47 @@ Start Properties: path=[directory] An additional class path element to add to the started class path. Typically this is used to add directories of classes and/or resources + lib=[directory] An additional library directory to add to the started class path. This must be a (deep) directory of jars + STOP.PORT=[number] The port to use to stop the running Jetty server. Required along with STOP.KEY if you want to use the --stop option above. + STOP.KEY=[alphanumeric] The passphrase defined to stop the server. Requried along with STOP.PORT if you want to use the --stop option above. + DEBUG=true Enable debug on the start mechanism and sets the org.eclipse.jetty.util.log.stderr.DEBUG system property to true. (default: false) - OPTIONS=[option,option,...] - Classpath Options to use. By convention, option names starting with capitals - will include associated options (eg Server includes jetty-server, jetty-webapp, - jetty-deploy, etc). An option starting with a lowercase letter includes - just the direct dependencies of the option (eg jsp includes just jetty-jsp - module and it's dependencies). - (default: "default,*") -@OPTIONS@ + OPTIONS=[option,option,...] + Enable classpath OPTIONS. Each options represents one or more jars + to be added to the classpath. The options are defined in + the start.config file and can be listed with --help or --list-options. + By convention, options starting with a capital letter (eg Server) + are aggregations of other available options. Available OPTIONS: -Configs: - XML Configurations to use. -@CONFIGS@ + @OPTIONS@ + + +Available Configurations: + By convention, configuration files are kept in $JETTY_HOME/etc. + The known configuration files are: + + @CONFIGS@ + + +Defaults: + A start.ini file may be used to specify default arguments to start.jar, + which are used if no command line arguments are provided and override + the defaults in the start.config file. If arguments are provided on the + command line, the special "%start.ini" argument may be used to include + the start.ini arguments and merge any OPTIONS. The current start.ini + arguments are: + + @STARTINI@ diff --git a/test-jetty-webapp/src/main/config/etc/jetty-testrealm.xml b/test-jetty-webapp/src/main/config/etc/jetty-testrealm.xml new file mode 100644 index 00000000000..c0d39fe497b --- /dev/null +++ b/test-jetty-webapp/src/main/config/etc/jetty-testrealm.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + Test Realm + /etc/realm.properties + 0 + + + + + diff --git a/jetty-server/src/main/config/etc/realm.properties b/test-jetty-webapp/src/main/config/etc/realm.properties similarity index 100% rename from jetty-server/src/main/config/etc/realm.properties rename to test-jetty-webapp/src/main/config/etc/realm.properties