From vs@lambda.foldr.org  Sun May 12 04:47:05 2002
Return-Path: <vs@lambda.foldr.org>
Received: from lambda.foldr.org (lambda.foldr.org [198.78.66.36])
	by hub.freebsd.org (Postfix) with ESMTP id D3D5837B401
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 12 May 2002 04:47:04 -0700 (PDT)
Received: from lambda.foldr.org (lambda.foldr.org [198.78.66.36])
	by lambda.foldr.org (8.12.3/8.11.6) with ESMTP id g4CBkmIS040381
	(using TLSv1/SSLv3 with cipher EDH-RSA-DES-CBC3-SHA (168 bits) verified OK);
	Sun, 12 May 2002 13:46:48 +0200 (CEST)
	(envelope-from vs@lambda.foldr.org)
Received: (from vs@localhost)
	by lambda.foldr.org (8.12.3/8.11.6/Submit) id g4CBklnK040369;
	Sun, 12 May 2002 13:46:47 +0200 (CEST)
	(envelope-from vs)
Message-Id: <200205121146.g4CBklnK040369@lambda.foldr.org>
Date: Sun, 12 May 2002 13:46:47 +0200 (CEST)
From: Volker Stolz <vs@lambda.foldr.org>
Reply-To: Volker Stolz <vs@lambda.foldr.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: vs@lambda.foldr.org
Subject: [PATCH] Fix Utils.java in textproc/cocoon
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         37989
>Category:       ports
>Synopsis:       [PATCH] Fix Utils.java in textproc/cocoon
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 12 04:50:01 PDT 2002
>Closed-Date:    Sun May 26 21:33:51 PDT 2002
>Last-Modified:  Sun May 26 21:33:51 PDT 2002
>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:
State-Changed-From-To: open->closed 
State-Changed-By: petef 
State-Changed-When: Sun May 26 21:33:42 PDT 2002 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=37989 
>Unformatted:
