Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 May 2002 13:46:47 +0200 (CEST)
From:      Volker Stolz <vs@lambda.foldr.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        vs@lambda.foldr.org
Subject:   ports/37989: [PATCH] Fix Utils.java in textproc/cocoon
Message-ID:  <200205121146.g4CBklnK040369@lambda.foldr.org>

next in thread | raw e-mail | index | archive | help

>Number:         37989
>Category:       ports
>Synopsis:       [PATCH] Fix Utils.java in textproc/cocoon
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 12 04:50:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Volker Stolz
>Release:        FreeBSD 4.5-RELEASE i386
>Organization:
Lambda Core Research Facility
>Environment:
System: FreeBSD lambda.foldr.org 4.5-RELEASE FreeBSD 4.5-RELEASE #0: Fri May 3 00:26:26 PDT 2002 user@jail2.johncompanies.com:/usr/src/sys/compile/6300 i386


	
>Description:
Cocoon-1.8.2 needs an important fix which somehow never made it into the tarball.
This patch (obtained from
http://www.mail-archive.com/cocoon-users@xml.apache.org/msg05651/Utils.java)
fixes the annoying issue when running the Cocoon samples in Tomcat:
"Error loading logicsheet at resource://org/apache/cocoon/processor/xsp/library/java/util.xsl"

>How-To-Repeat:
 - install tomcat/jakarta
 - install cocoon
 - install samples from cocoon-tarball into tomcat, try to view the samples (*.xml):
      you get the Java error above.
>Fix:
Put the following patch into textproc/cocoon/files/patch-ac:

--- src/org/apache/cocoon/Utils.java.orig	Sun May 12 13:30:49 2002
+++ src/org/apache/cocoon/Utils.java	Sun May 12 13:30:58 2002
@@ -75,7 +75,7 @@
     throws UnsupportedEncodingException {
         return (encoding == null) ? s.getBytes () : s.getBytes (encoding);
     }
-                                                                                                  
+
     /**
      * This method returns a vector of PI nodes based on the PI target name.
      */
@@ -151,7 +151,7 @@
         while (nodes.hasMoreElements()) {
             ProcessingInstruction pi = (ProcessingInstruction) nodes.nextElement();
             addPIPseudoAttributes(pi, attributes);
-        }   
+        }
         return attributes;
     }
 
@@ -181,13 +181,13 @@
               String key   = st.nextToken();     // attribute name and '='
               String token = st.nextToken();     // exact attribute value
               key = key.replace('=',' ').trim(); // remove whitespace and '='
-              attributes.put(key, token);    
+              attributes.put(key, token);
           }
         } catch (NoSuchElementException nsee) {
           // ignore white-space at the end of pseudo-list
         }
     }
-    
+
     /**
      * Encodes the given request into a string using the format
      *   protocol://serverName:serverPort/requestURI?query
@@ -257,7 +257,7 @@
      */
     public static final String getBasename(HttpServletRequest request, Object context) {
         String path;
-        
+
         try {
             // detect if the engine supports at least Servlet API 2.2
             request.getClass ().getMethod ("getContextPath", null);
@@ -310,11 +310,11 @@
      */
     public static final String getRootpath(HttpServletRequest request, Object context) {
         // FIXME (SM): I have _no_absolute_idea_ how much this is portable. The whole
-        // architecture should be based on URL rather than Files to allow the 
+        // architecture should be based on URL rather than Files to allow the
         // use of Servlet 2.2 getResource() to void calling such nasty methods
         // but for now, well, it's the best I can do :(
         return request.getRealPath("/");
-    }    
+    }
 
     /*
      * Returns the stack trace as a string
@@ -331,16 +331,20 @@
      */
     public static final Object getLocationResource(String location) throws MalformedURLException {
         Object resource = null;
-        
+
         if (location.indexOf("://") < 0) {
             resource = new File(location);
         } else if (location.startsWith("resource://")) {
             // FIXME (SM): this should _not_ be system resource, but rather a resource of current classloader
-            resource = ClassLoader.getSystemResource(location.substring("resource://".length()));
+//            resource = ClassLoader.getSystemResource(location.substring("resource://".length()));
+
+            // The Fix!
+            Dummy classloadrefernce = new Dummy();
+            resource = classloadrefernce.getClass().getClassLoader().getResource(location.substring("resource://".length()));
         } else {
             resource = new URL(location);
         }
-        
+
         return resource;
     }
 
@@ -349,7 +353,7 @@
      */
     public static final Object getLocationResource(String location, HttpServletRequest request, ServletContext context) throws Exception {
         Object resource = null;
-        
+
         if (location.indexOf("://") < 0) {
             if (location.charAt(0) == '/') {
                 // Location is relative to webserver's root
@@ -362,11 +366,20 @@
             resource = new File(location);
         } else if (location.startsWith("resource://")) {
             // FIXME (SM): this should _not_ be system resource, but rather a resource of current classloader
-            resource = ClassLoader.getSystemResource(location.substring("resource://".length()));
+//            resource = ClassLoader.getSystemResource(location.substring("resource://".length()));
+
+            // The Fix!
+            Dummy classloadrefernce = new Dummy();
+            resource = classloadrefernce.getClass().getClassLoader().getResource(location.substring("resource://".length()));
         } else {
             resource = new URL(location);
         }
-        
+
         return resource;
     }
+
+}
+
+class Dummy {
+    String why = "to provide a classloader ref";
 }
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200205121146.g4CBklnK040369>