Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 367591

Summary: Support Env variables in XmlConfiguration
Product: [RT] Jetty Reporter: Greg Wilkins <gregw>
Component: serverAssignee: Shirley Boulay <boulay>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: hmalphettes, jetty-inbox, simbo1905
Version: 7.6.0.RC0   
Target Milestone: 7.5.x   
Hardware: All   
OS: All   
Whiteboard:

Description Greg Wilkins CLA 2011-12-27 19:08:52 EST
Support Env variables in XmlConfiguration
Comment 1 Greg Wilkins CLA 2011-12-27 19:25:03 EST
I have implemented this with the new tag "Env" that will be in 7.6 onwards.

An example is:

  <Env name="HOME"/>

which expands to the string value of the HOME environment variable.  You can also have a default value if HOME is not set:

  <Env name="HOME" default="value"/>


The Env element can be used anywhere a value is expected (just like the SystemProperty element).
Comment 2 Hugues Malphettes CLA 2011-12-30 20:00:08 EST
Thanks Greg!
Comment 3 Simon CLA 2012-06-17 03:40:42 EDT
Can we have an example please? You show how to define it but how to use it to set something like the --host option to get the server to bind to the correct interface on a cloud platform? 

I am trying to use this feature with jetty-runner version 7.6.4.v20120524 and it gives an error that the xml syntax is unknown: 

2012-06-17 08:30:51.340:WARN:oejx.XmlConfiguration:Config error at <Env name="INTERFACE" default="1.2.3.4"/> java.lang.IllegalStateException: Unknown tag: Env
java.lang.IllegalStateException: Unknown tag: Env
	at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:394)
	at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:320)
	at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:279)
	at org.mortbay.jetty.runner.Runner.configure(Runner.java:263)
	at org.mortbay.jetty.runner.Runner.main(Runner.java:624)