cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ro...@promca.com
Subject Using IBM WebSphere AppServer and VisualAge
Date Mon, 02 Oct 2000 22:26:45 GMT
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);
    }

Mime
View raw message