This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Null Pointer in RequestUtils.

 
Rich Smyth
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When trying to access my index.jsp I get an immediate null pointer exception in RequestUtils.
I've used the <logic:redirect> tag successfully in the past but I can't see what I've done wrong this time.
My previous experience (when this was working) was with version 1.1-rc2 now I'm using 1.1.
Any help as to why this exception is happening would be much appreciated.
I've included details below.

My index.jsp is simply:
<%@ taglib uri="/tld/struts-logic" prefix="logic" %>
<logic:redirect forward="greetings" />
In my struts-config I have:
<global-forwards type="org.apache.struts.action.ActionForward">
<forward name="greetings" path="/greetings.do" redirect="false" />
</global-forwards>
<action path="/greetings"
type="org.apache.struts.actions.ForwardAction"
parameter="/WEB-INF/pages/greetingTest.jsp" />

The exception when I enter myContext/index.jsp is:
org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause
java.lang.NullPointerException
org.apache.struts.util.RequestUtils.computeURL(RequestUtils.java:521)
org.apache.struts.util.RequestUtils.computeURL(RequestUtils.java:436)
org.apache.struts.util.RequestUtils.computeURL(RequestUtils.java:396)
org.apache.struts.taglib.logic.RedirectTag.doEndTag(RedirectTag.java:294)
org.apache.jsp.index_jsp._jspx_meth_logic_redirect_0(index_jsp.java:82)
org.apache.jsp.index_jsp._jspService(index_jsp.java:58)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
I looked at the RequestUtils source and I think that the MODULE_KEY attribute (request and application scope) is null. However
I can't figure out why my configuration would be causing this.
Rich
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having a hard time figuring out what you want to do here. The best I can figure is that you do not want the user's address bar to show .do at the end.
I don't think a request will hit the Struts Controller unless it follows the pattern mapped to the Controller in your web.xml. Maybe you could change the pattern from *.do to something else, like myapp/*
Wouldn't hurt to at least see if that's the problem. Good luck Rich!
 
Rich Smyth
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having a hard time figuring out what you want to do here.

I want to test the welcome file defined in my web.xml
<welcome-file>/index.jsp</welcome-file>
When I entered myContext/ on the address line I got the error described I my original email.
Rich
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh. Get rid of the global-forwards' forward and have index.jsp forward to greetings.do instead of just greetings.
The Struts controller will direct this to the action mapped to the path /greetings
The web.xml sees that it ends in .do and sends it to the Struts Controller.
The Struts Controller then knows to remove the .do and finds the mapping of / + the request sans .do
In this case greetings.do would be directed automagically to the action mapped with the path="/greetings"
Right now your jsp is forwarding to "greetings". Because it does not end in .do, it never gets sent to the Struts Controller and so the struts-config never comes in to play.
 
Jo�l Rouiller
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Rich,
I had the exactly same problem and found a solution (for me)!
I develop my web application in Eclipse with Tomcat 5.0.19. Trying to deploy it with Tomcat 4.1.8 and 4.1.30 results in the problem you encountred.
So, if you develop/run with Tomcat try to upgrade to 5.0.19 if you can.
Best regards,
Jo�l
 
Dave Knipp
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting the same error when using logic:redirect. I get the request utils null pointer no matter if i use a global forward or a direct forward to the action itself.

Has anyone figured this out other than changing server versions? Is it api related? Maybe there are some struts dependent libraries that are out of sync with what is expected?

Any help would be great.

Thansk,
Dave
 
Monica Singhal
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had the similar problem. Everything worked fine yesterday when i left and today when i tried to run the application it just gave that error.

I couldnt find any reason behind it. As code was perfectly alright. Tried a couple of things(even rebooted the computer), nothing worked.

I was using eclipse as the IDE for my application so finally, "clean" the project and run it again. It worked for me.

May be its a bug in Tomcat. I am not sure if they have handled it in new versions or not. I was however using Tomcat 5.0.28
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic