Return-Path: Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 18891 invoked from network); 2 Oct 2000 22:25:51 -0000 Received: from out5.prserv.net (HELO prserv.net) (32.97.166.35) by locus.apache.org with SMTP; 2 Oct 2000 22:25:51 -0000 Received: from promca.com ([166.72.64.182]) by prserv.net (out5) with SMTP id <20001002222549205059tg6ue>; Mon, 2 Oct 2000 22:25:50 +0000 Message-ID: <39D90BA5.732C364A@promca.com> Date: Mon, 02 Oct 2000 18:26:45 -0400 From: robmv@promca.com Reply-To: robmv@promca.com Organization: =?iso-8859-1?Q?Programaci=F3n?= Mecanizada C.A. X-Mailer: Mozilla 4.7 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 To: cocoon-dev@xml.apache.org Subject: Using IBM WebSphere AppServer and VisualAge Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N HI.... I�m using Cocoon inside VisualAge for Java 3.02 using the WebSphere test environment, and I�m experiencing two problems that I patched In the method "getBasename(HttpServletRequest, Object)" in class "org.apache.cocoon.Utils", there is a workaround that doesn�t work in my environment. a) The call to request.getContextPath() throws an java.lang.IncompatibleClassChangeError and no an java.lang.NoSuchMethodError, so the workaround doesn�t work b) Changing the method and using only the code inside the catch for NoSuchMethodError doesn�t work well, because WebSphere includes the concept of Web applications even when the servlet APIs are 2.1 version, so if my web app is configured inside the web path "/probject", the code generates a resorce path like this one "D:/ibmvjava/ide/project_resources/IBM WebSphere Test Environment/host/default_host/default_app/web/probject/probject/index.xml": please note the reference to "probject" repeated. If I use the code designed for the 2.2 Servlet API, this works perfectly. c) Another problem exist when I try to load this samples "xsp/view-source.xml?filename=page.xml". This XSP file uses the method XSPUtil.relativeFilename(...), that returns a file reference to the relative filename that was requested in the filename parameter. This method fails to return a valid file and signals a problem that the file is not found. to correct this I removed the "replace('\\','/')" method call because this returns invalid file paths for OS/2 and Windows platforms. This change forced me correct the method getBasepath(HttpServletRequest, Object) in class "org.apache.cocoon.Utils" I think that this solve all problems with WebSphere, I know that this patch made this class incompatible with JServ, I don�t know if this affects Tomcat too. The code that detects the servlet path when the request is included in a servlet or jsp works perfectly in WebSphere App Server 3.02 but not always in VisualAge for Java WebSphere Test Environment This are the final methods that I temporaly patched; Sorry, but i don�t now how to use CVS, I�m downloading it now, I don�t know how to generate a diff file /*--------------------------------------------------------------------------------------------*/ public static final String getBasename(HttpServletRequest request, Object context) { String path; try { // detect if the engine supports at least Servlet API 2.2 (Removed for problems with WebSphere) // request.getContextPath(); // we need to check this in case we've been included in a servlet or jsp path = (String) request.getAttribute("javax.servlet.include.servlet_path"); // otherwise, we find it out ourselves if (path == null) path = request.getServletPath(); // FIXME (SM): we should use getResource() instead when we are // able to handle remote resources. String resource = ((ServletContext) context).getRealPath(path); if (resource != null) { return resource; } else { throw new RuntimeException("Cannot access non-file/war resources"); } } catch (IncompatibleClassChangeError e) { // if there is no such method we must be in Servlet API 2.1 if (request.getPathInfo() != null) { // this must be Apache JServ path = request.getPathTranslated(); } else { // otherwise use the deprecated method on all other servlet engines. path = request.getRealPath(request.getRequestURI()); } return (path == null) ? "" : path; } catch (NullPointerException e) { // if there is no context set, we must be called from the command line return request.getPathTranslated(); } } /*--------------------------------------------------------------------------------------------*/ public static final String getBasepath(HttpServletRequest request, Object context) { String basename = getBasename(request, context); return basename.substring(0, basename.lastIndexOf(File.separatorChar) + 1); }