tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jocelyn Ireson-Paine <>
Subject Null-pointer exception from response.encodeUrl under Windows Tomcat 7
Date Thu, 09 Jun 2011 03:53:39 GMT

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 

Here's a trace of the error:
 	at sharesim.ValueGame.encodeUrl(
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 
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";
       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:

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.

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

Jocelyn's Cartoons:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message