tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1578369 - in /tomcat/tc6.0.x/trunk: ./ STATUS.txt java/org/apache/tomcat/util/descriptor/DigesterFactory.java java/org/apache/tomcat/util/descriptor/LocalStrings.properties webapps/docs/changelog.xml
Date Mon, 17 Mar 2014 13:43:20 GMT
Author: markt
Date: Mon Mar 17 13:43:20 2014
New Revision: 1578369

URL: http://svn.apache.org/r1578369
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56236
Fix issue with Tomcat running in environments (e.g. OSGI) with alternative Servlet and JSP
API implementations that package the XML schemas differently

Modified:
    tomcat/tc6.0.x/trunk/   (props changed)
    tomcat/tc6.0.x/trunk/STATUS.txt
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/DigesterFactory.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/LocalStrings.properties
    tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc6.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1577315,1577324,1577463
  Merged /tomcat/tc7.0.x/trunk:r1577328,1577464-1577465

Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=1578369&r1=1578368&r2=1578369&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Mon Mar 17 13:43:20 2014
@@ -65,13 +65,6 @@ PATCHES PROPOSED TO BACKPORT:
   +1: kkolinko, markt
   -1:
 
-* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56236
-  Fix issue with Tomcat running in environments (e.g. OSGI) with alternative
-  Servlet and JSP API implementations that package the XML schemas differently
-  http://people.apache.org/~markt/patches/2014-03-14-osgi-resources-tc6-v2.patch
-  +1: markt, kkolinko, violetagg
-  -1:
-
 * Improve processing of chuck size from chunked headers. Avoid overflow and use
   a bit shift instead of a multiplication as it is marginally faster.
   http://people.apache.org/~markt/patches/2014-03-17-chunked-headers-tc6-v1.patch

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/DigesterFactory.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/DigesterFactory.java?rev=1578369&r1=1578368&r2=1578369&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/DigesterFactory.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/DigesterFactory.java Mon Mar
17 13:43:20 2014
@@ -23,8 +23,11 @@ import java.util.Map;
 
 import javax.servlet.ServletContext;
 
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.digester.Digester;
 import org.apache.tomcat.util.digester.RuleSet;
+import org.apache.tomcat.util.res.StringManager;
 import org.xml.sax.ext.EntityResolver2;
 
 /**
@@ -33,6 +36,25 @@ import org.xml.sax.ext.EntityResolver2;
  */
 public class DigesterFactory {
 
+    private static final Log log = LogFactory.getLog(DigesterFactory.class);
+    private static final StringManager sm =
+            StringManager.getManager(Constants.PACKAGE_NAME);
+
+    private static final Class<ServletContext> CLASS_SERVLET_CONTEXT;
+    private static final Class<?> CLASS_JSP_CONTEXT;
+
+    static {
+        CLASS_SERVLET_CONTEXT = ServletContext.class;
+        Class<?> jspContext = null;
+        try {
+            jspContext = Class.forName("javax.servlet.jsp.JspContext");
+        } catch (ClassNotFoundException e) {
+            // Ignore - JSP API is not present.
+        }
+        CLASS_JSP_CONTEXT = jspContext;
+    }
+
+
     /**
      * Mapping of well-known public IDs used by the Servlet API to the matching
      * local resource.
@@ -50,31 +72,31 @@ public class DigesterFactory {
         Map<String, String> systemIds = new HashMap<String, String>();
 
         // W3C
-        publicIds.put(XmlIdentifiers.XSD_10_PUBLIC, idFor("XMLSchema.dtd"));
-        publicIds.put(XmlIdentifiers.DATATYPES_PUBLIC, idFor("datatypes.dtd"));
-        systemIds.put(XmlIdentifiers.XML_2001_XSD, idFor("xml.xsd"));
+        add(publicIds, XmlIdentifiers.XSD_10_PUBLIC, locationFor("XMLSchema.dtd"));
+        add(publicIds, XmlIdentifiers.DATATYPES_PUBLIC, locationFor("datatypes.dtd"));
+        add(systemIds, XmlIdentifiers.XML_2001_XSD, locationFor("xml.xsd"));
 
         // from J2EE 1.2
-        publicIds.put(XmlIdentifiers.WEB_22_PUBLIC, idFor("web-app_2_2.dtd"));
-        publicIds.put(XmlIdentifiers.TLD_11_PUBLIC, idFor("web-jsptaglibrary_1_1.dtd"));
+        add(publicIds, XmlIdentifiers.WEB_22_PUBLIC, locationFor("web-app_2_2.dtd"));
+        add(publicIds, XmlIdentifiers.TLD_11_PUBLIC, locationFor("web-jsptaglibrary_1_1.dtd"));
 
         // from J2EE 1.3
-        publicIds.put(XmlIdentifiers.WEB_23_PUBLIC, idFor("web-app_2_3.dtd"));
-        publicIds.put(XmlIdentifiers.TLD_12_PUBLIC, idFor("web-jsptaglibrary_1_2.dtd"));
+        add(publicIds, XmlIdentifiers.WEB_23_PUBLIC, locationFor("web-app_2_3.dtd"));
+        add(publicIds, XmlIdentifiers.TLD_12_PUBLIC, locationFor("web-jsptaglibrary_1_2.dtd"));
 
         // from J2EE 1.4
-        systemIds.put("http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd",
-                idFor("j2ee_web_services_1_1.xsd"));
-        systemIds.put("http://www.ibm.com/webservices/xsd/j2ee_web_services_client_1_1.xsd",
-                idFor("j2ee_web_services_client_1_1.xsd"));
-        systemIds.put(XmlIdentifiers.WEB_24_XSD, idFor("web-app_2_4.xsd"));
-        systemIds.put(XmlIdentifiers.TLD_20_XSD, idFor("web-jsptaglibrary_2_0.xsd"));
+        add(systemIds, "http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd",
+                locationFor("j2ee_web_services_1_1.xsd"));
+        add(systemIds, "http://www.ibm.com/webservices/xsd/j2ee_web_services_client_1_1.xsd",
+                locationFor("j2ee_web_services_client_1_1.xsd"));
+        add(systemIds, XmlIdentifiers.WEB_24_XSD, locationFor("web-app_2_4.xsd"));
+        add(systemIds, XmlIdentifiers.TLD_20_XSD, locationFor("web-jsptaglibrary_2_0.xsd"));
         addSelf(systemIds, "j2ee_1_4.xsd");
         addSelf(systemIds, "jsp_2_0.xsd");
 
         // from JavaEE 5
-        systemIds.put(XmlIdentifiers.WEB_25_XSD, idFor("web-app_2_5.xsd"));
-        systemIds.put(XmlIdentifiers.TLD_21_XSD, idFor("web-jsptaglibrary_2_1.xsd"));
+        add(systemIds, XmlIdentifiers.WEB_25_XSD, locationFor("web-app_2_5.xsd"));
+        add(systemIds, XmlIdentifiers.TLD_21_XSD, locationFor("web-jsptaglibrary_2_1.xsd"));
         addSelf(systemIds, "javaee_5.xsd");
         addSelf(systemIds, "jsp_2_1.xsd");
         addSelf(systemIds, "javaee_web_services_1_2.xsd");
@@ -85,17 +107,29 @@ public class DigesterFactory {
     }
 
     private static void addSelf(Map<String, String> ids, String id) {
-        String systemId = idFor(id);
-        ids.put(systemId, systemId);
-        ids.put(id, systemId);
+        String location = locationFor(id);
+        if (location != null) {
+            ids.put(id, location);
+            ids.put(location, location);
+        }
+    }
+
+    private static void add(Map<String,String> ids, String id, String location) {
+        if (location != null) {
+            ids.put(id, location);
+        }
     }
 
-    private static String idFor(String url) {
-        URL id = ServletContext.class.getResource("resources/" + url);
-        if (id == null) {
-            id = ServletContext.class.getResource("jsp/resources/" + url);
+    private static String locationFor(String name) {
+        URL location = CLASS_SERVLET_CONTEXT.getResource("resources/" + name);
+        if (location == null && CLASS_JSP_CONTEXT != null) {
+            location = CLASS_JSP_CONTEXT.getResource("resources/" + name);
+        }
+        if (location == null) {
+            log.warn(sm.getString("digesterFactory.missingSchema", name));
+            return null;
         }
-        return id.toExternalForm();
+        return location.toExternalForm();
     }
 
 

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/LocalStrings.properties?rev=1578369&r1=1578368&r2=1578369&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/LocalStrings.properties (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/LocalStrings.properties Mon
Mar 17 13:43:20 2014
@@ -13,6 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+digesterFactory.missingSchema=The XML schema [{0}] could not be found. This is very likely
to break XML validation if XML validation is enabled.
+
 localResolver.unresolvedEntity=Could not resolve XML resource [{0}] with public ID [{1}],
system ID [{2}] and base URI [{3}] to a known, local entity.
 
 xmlErrorHandler.error=Non-fatal error [{0}] reported processing [{1}].

Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=1578369&r1=1578368&r2=1578369&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Mon Mar 17 13:43:20 2014
@@ -44,6 +44,16 @@
  General, Catalina, Coyote, Jasper, Cluster, Web applications, Other
 -->
 <section name="Tomcat 6.0.40" rtext="">
+  <subsection name="Catalina">
+    <changelog>
+      <fix>
+        Enable Tomcat to work with alternative Servlet and JSP API JARs that
+        package the XML schemas in such as way as to require a dependency on the
+        JSP API before enabling validation for web.xml. Tomcat has no such
+        dependency. (markt)
+      </fix>
+    </changelog>
+  </subsection>
   <subsection name="Web applications">
     <changelog>
       <add>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message