--- Mark McBride <[EMAIL PROTECTED]> wrote: > I may have found a problem using Struts/StrutsTestCase with OC4J(9.0.4). > > Background: I'm running a StrutsTestCase that works in Resin 2.x but > when > ran in OC4J I get a NullPointerException from > org.apache.struts.util.RequestUtils.java line 1806. The problem I found > with both the RequestUtils.java and CactusStrutsTestCase.java are > illustrated below. > > The problem can be found in two places. The first is in > CactusStrutsTestCase.java line 417: > String moduleName = (String) > request.getAttribute(Common.INCLUDE_SERVLET_PATH); > if (moduleName.endsWith("/")) > moduleName = moduleName.substring(0,moduleName.lastIndexOf("/")); > > In resin 2.X this runs correctly with moduleName being initialized to "" > > even if the attribute is not found. > In oc4j 9.0.4 request.getAttribute returns "null" when an attribute is > not > found. When moduleName.endsWith gets executed a NullPointerException is > thrown. > > The second is in org.apache.struts.util.RequestUtils.java introduced in > line 1783 blows up on line 1806: > On line 1783 (same fundamental problem as the first error): > String matchPath = (String) > request.getAttribute(RequestProcessor.INCLUDE_SERVLET_PATH); > // matchPath is set to "" in resin matchPath is null in oc4j > if (matchPath == null) { > matchPath = request.getServletPath(); > } > return getModuleName( matchPath, context); > > Both calls to request.getXXX return an empty string in resin. In oc4j > null > is returned. > The error is surfaced on line 1806: > while (prefix.equals("") && ((lastSlash = matchPath.lastIndexOf("/")) > > 0)) { > > Since the call to getModuleName passes in null, matchPath.lastIndexOf > throws a NullPointerException. > > Good news is that this is open-source and I can hack the code for myself > > =). I'm curious of all the other sections of code in struts that make > the > assumption that the request object will return an instantiated object > and > not "null".? It appears that the servlet 2.3 specification specifies > that > returning null is the correct servlet implementation. > http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletRequest.html#getAttribute(java.lang.String) > > What is the best way to file bugs for both struts and strutstestcase?
Struts bugs are entered into bugzilla: http://nagoya.apache.org/bugzilla/ StrutsTestCase is an independent SourceForge project. Both of the containers you mentioned are non-free which really limits what we can do to test the problem. I believe the majority of us are using Tomcat because it's the free reference implementation of the Servlet and JSP specs. Tomcat should implement the specs *exactly* so if it fails there, it's most likely a Struts bug. David > > Thanks in advance! > > -Mark > __________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]