tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Schumacher <felix.schumac...@internetallee.de>
Subject Re: Null-pointer exception from response.encodeUrl under Windows Tomcat 7
Date Thu, 09 Jun 2011 07:18:16 GMT
Am Donnerstag, den 09.06.2011, 04:53 +0100 schrieb Jocelyn Ireson-Paine:
> Hi,
> 
> I'm getting sporadic null-pointer exceptions from 'response.encodeUrl'. 
> This is with Tomcat 7.0.14, the latest stable version to which I upgraded 
> an hour ago, and Java 1.6.0_26, which again I upgraded to at the same 
> time, under Windows XP. I also got the error under Tomcat 5.5.33, which is 
> why I tried upgrading. I uninstalled old Tomcats and Javas before 
> upgrading.
> 
> Here's a trace of the error:
>    java.lang.NullPointerException
>  	at 
> org.apache.catalina.connector.Response.toAbsolute(Response.java:1594)
>  	at 
> org.apache.catalina.connector.Response.encodeURL(Response.java:1198)
>  	at 
> org.apache.catalina.connector.ResponseFacade.encodeUrl(ResponseFacade.java:422)
>  	at sharesim.ValueGame.encodeUrl(ValueGame.java:468)
> The fourth line of the trace is my code.
> 
> To get some diagnostics, I encapsulated 'response.encodeUrl' in the 
> following method, and used 'println' to print to Tomcat's log. This method 
You can use the servlet api's log method to log inside a web
application, or even better use a logging-framework.

> is the one mentioned on the fourth line of the above trace.
>    private final static String encodeUrl( HttpServletResponse response
>                                         , String url
>                                         )
>    {
>      System.out.println( "encodeUrl" );
>      System.out.println( "response=" + response );
>      System.out.println( "url=" + url );
>      String result = null;
>      if ( response == null )
>        result = "not on Web";
>      else
>        result = response.encodeUrl( url );
>      System.out.println( "result=" + result );
>      return result;
>    }
> 
> As mentioned above, the errors are sporadic. My redirection code gets 
> called on my server when I submit one of my forms. But sometimes, the 
> submit works; sometimes it doesn't. Here are two successive traces from 
> the above method:
>    encodeUrl
>    response=org.apache.catalina.connector.ResponseFacade@1a5ec6c
>    url=/ResearcherValueGame1.jsp
>    result=/ResearcherValueGame1.jsp
> 
>    encodeUrl
>    response=org.apache.catalina.connector.ResponseFacade@1a5ec6c
>    url=/ResearcherValueGame1.jsp
> The first one worked; the second crashed rather than returning the encoded 
> URL. The URL to be encoded is the same in both cases, and 'response' is 
> evidently the same instance. I don't know how to dump 'response' in order 
> to show relevant fields (whichever they are), but am happy to try it if 
> someone can suggest how.
You haven't shown us the code, which calls your encodeUrl. Most of the
times someone reports sporadic errors while working with responses, he
is saving references to the responses in a class variable.

Could this be your problem?

Felix
> 
> I've found a few mentions on Google of such errors, but nothing definite 
> about it happening in Tomcat 7. One discussion which I thought I'd seen, 
> but can't find again, seemed to suggest that the problem occurred on 
> version 5, possibly because of a missing 'synchronized'. I've not seen 
> anything in recent postings to this list.
> 
> I wondered whether the problem might be caused by the browser creating 
> malformed cookies, or some such. (I'm using session-handling.) However, 
> this seems unlikely, as the error occurs regardless of whether I use 
> Firefox, Internet Explorer, or Google Chrome.
> 
> Any ideas?
> 
> Jocelyn Ireson-Paine
> http://www.j-paine.org
> 
> Jocelyn's Cartoons:
> http://www.j-paine.org/blog/jocelyns_cartoons/
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message