Community
Participate
Working Groups
jetty-web.xml files that appear in a war file that date from jetty6 can kill the deployment of a war file since it is largely packaging changes we should be able to process these files and translate to jetty7+ on the fly
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