History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: STR-2805
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Don Brown
Reporter: Shailesh
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Struts 1

java.lang.NullPointerException

Created: 23/Mar/06 09:23 AM   Updated: 03/Jul/07 08:36 PM
Component/s: Tag Libraries
Affects Version/s: Future
Fix Version/s: 1.3.3

Environment:
Operating System: Windows NT
Platform: Other

Bugzilla Id: http://issues.apache.org/bugzilla/show_bug.cgi?id=39074


 Description  « Hide
I m using Struts-1.2.0 and Tomcat 4.1.30.
I have a link in my "index.jsp" that uses 'forward' attribute of <html:link> to
transfer to a page called "xyz.jsp".
For your reference the code snippet is as below:
---------------------------------------------
  In index.jsp ->
      <html:link forward="xyzForward"> XYZ Form </html:link>
   
  In struts-config.xml ->
     <global-forwards>
     <forward name="xyzForward"
          path="/xyz.jsp"/>
     </global-forwards>
---------------------------------------
And i get the HTTP Status 500 Internal Server Error: The root cause is as
follows: (only the initial 4 lines is listed)

java.lang.NullPointerException
at org.apache.struts.taglib.TagUtils.computeURLWithCharEncoding
(TagUtils.java:487)
at org.apache.struts.taglib.TagUtils.computeURLWithCharEncoding
(TagUtils.java:370)
at org.apache.struts.taglib.html.LinkTag.calculateURL(LinkTag.java:514)
at org.apache.struts.taglib.html.LinkTag.doStartTag(LinkTag.java:374)
                                     "
--------------------------------------
Note : With "href" and "action" attributes of <html:link> the index.jsp is
getting displayed but exception occurs while using "forward" and "page"
attributes.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Eric Hughes - 04/Apr/06 09:04 PM
This defect also appears in struts-1.2.9.

Source of error:
TagUtils.java:422:
ModuleConfig moduleConfig = instance.getModuleConfig(module, pageContext);
TagUtils.java:428:
ForwardConfig forwardConfig = moduleConfig.findForwardConfig(forward);

The problem is that "getModuleConfig" is allowed to return null (see its
implementation, where this is documented). If it does return null, however,
there's no check for it, nor any alternate action. Dereferencing it in line 428
generates the exception.

Eric Hughes - 04/Apr/06 09:29 PM
(In reply to comment #1)
> TagUtils.java:422:
> ModuleConfig moduleConfig = instance.getModuleConfig(module, pageContext);
> TagUtils.java:428:
> ForwardConfig forwardConfig = moduleConfig.findForwardConfig(forward);

Still no null-pointer check in 1.3.0 snapshot.

Eric Hughes - 04/Apr/06 11:23 PM
This particular problem can be masked by initializing servlet "action" with
param-name "config/" rather than "config". This appears to make a module
context that exists (non-null pointer) with an empty name.