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

Bug 355854

Summary: add ability to process jetty-web.xml from jetty6
Product: [RT] Jetty Reporter: Jesse McConnell <jesse.mcconnell>
Component: serverAssignee: 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 CLA 2011-08-25 10:51:08 EDT
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
Comment 1 Jesse McConnell CLA 2011-08-25 12:23:35 EDT
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;
+    }
+    
 }
Comment 2 Jesse McConnell CLA 2011-08-25 18:06:22 EDT
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
Comment 3 Jesse McConnell CLA 2011-08-26 12:13:19 EDT
closing, resolved via throwing a warning message if jetty-web.xml can not be processed but it no longer kills deployment outright