| Summary: | add ability to process jetty-web.xml from jetty6 | ||
|---|---|---|---|
| Product: | [RT] Jetty | Reporter: | Jesse McConnell <jesse.mcconnell> |
| Component: | server | Assignee: | Jesse McConnell <jesse.mcconnell> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | gregw, jetty-inbox |
| Version: | unspecified | ||
| Target Milestone: | 7.5.x | ||
| Hardware: | PC | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
|
Description
Jesse McConnell
Greg, how adverse to this hack would you be?
basically in JettyWebXmlConfiguration we check if there is an old jetty-web.xml file and automatically translate it to the correct class name, while issuing a WARNING.
this works for the latest ehcache-server.war file I am testing with
--- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/JettyWebXmlConfiguratio
+++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/JettyWebXmlConfiguratio
@@ -13,8 +13,10 @@
package org.eclipse.jetty.webapp;
+import java.io.InputStream;
import java.util.Map;
+import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.xml.XmlConfiguration;
@@ -77,12 +79,28 @@ public class JettyWebXmlConfiguration extends AbstractConfigu
{
context.setServerClasses(null);
if(Log.isDebugEnabled())
+ {
Log.debug("Configure: "+jetty);
+ }
+
XmlConfiguration jetty_config = (XmlConfiguration)context.ge
+
if (jetty_config==null)
- jetty_config=new XmlConfiguration(jetty.getURL());
+ {
+ String jettyXml = IO.toString(jetty.getURL().openStream(
+
+ if ( jettyXml.contains("org.mortbay.") )
+ {
+ Log.warn("Detected jetty 6 configuration, attempting
+ jettyXml = convertFromJetty6(jettyXml);
+ }
+
+ jetty_config=new XmlConfiguration(jettyXml);
+ }
else
+ {
context.removeAttribute(XML_CONFIGURATION);
+ }
setupXmlConfiguration(context,jetty_config, web_inf);
jetty_config.configure(context);
}
@@ -116,4 +134,21 @@ public class JettyWebXmlConfiguration extends AbstractConfig
props.put(PROPERTY_THIS_WEB_INF_URL, String.valueOf(web_inf.getURL()));
}
+ /*
+ * convert specific o.m.jetty paths to o.e.jetty paths
+ */
+ private String convertFromJetty6(String jettyXml)
+ {
+ // XMLConfiguration(String) will tack on <?xml directives, so make sure
+ // the Configure
+ if ( !jettyXml.startsWith("<Configure"))
+ {
+ jettyXml = jettyXml.substring(jettyXml.indexOf("<Configure"));
+ }
+
+ jettyXml = jettyXml.replace("org.mortbay.jetty.webapp.WebAppContext","or
+
+ return jettyXml;
+ }
+
}
Note, I have this committed locally and am leveraging it for the ehcache session testing in the jetty-ehcache-sessions project in the jetty-sandbox closing, resolved via throwing a warning message if jetty-web.xml can not be processed but it no longer kills deployment outright |