Bug 32708 - NullPointer for every request
Summary: NullPointer for every request
Status: RESOLVED INVALID
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Unknown (show other bugs)
Version: 5.5.4
Hardware: PC Windows XP
: P2 normal with 1 vote (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-15 00:06 UTC by Erik Pragt
Modified: 2004-12-15 03:57 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Pragt 2004-12-15 00:06:16 UTC
When doing a request.getParameter, or a request.getParameterNames, the Tomcat
Server comes up with this message:
Dec 14, 2004 11:53:28 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet controller threw exception
java.lang.NullPointerException
	at org.apache.tomcat.util.buf.StringCache$ByteEntry.hashCode(StringCache.java:633)
	at java.util.HashMap.hash(Unknown Source)
	at java.util.HashMap.get(Unknown Source)
	at org.apache.tomcat.util.buf.StringCache.toString(StringCache.java:284)
	at org.apache.tomcat.util.buf.ByteChunk.toString(ByteChunk.java:461)
	at org.apache.tomcat.util.http.Parameters.urlDecode(Parameters.java:411)
	at org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:391)
	at org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:504)
	at
org.apache.tomcat.util.http.Parameters.handleQueryParameters(Parameters.java:265)
	at org.apache.catalina.connector.Request.parseParameters(Request.java:2299)
	at org.apache.catalina.connector.Request.getParameter(Request.java:991)
	at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:262)
	at nl.printfill.controller.Controller.process(Controller.java:86)
	at nl.printfill.controller.Controller.doGet(Controller.java:62)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
	at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
	at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
	at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
	at java.lang.Thread.run(Unknown Source)


This is (part of) the code which procudures the error:


    HttpSession session = request.getSession();

    String actionName = request.getParameter(Action.ACTION);  // line 86

    if(actionName != null)
    {
      Action action = (Action) ActionFactory.getAction(actionName);


Erik
Comment 1 Remy Maucherat 2004-12-15 00:15:35 UTC
Do you see this in conf/catalina.properties:
tomcat.util.buf.StringCache.byte.enabled=true ?
So you can easily work around the problem.
Comment 2 Remy Maucherat 2004-12-15 00:26:55 UTC
I don't understand what causes the bug. Can you submit a better test case
(similar code runs fine for me) ?

It's really odd that you're getting an exception there, because it can only
happen if the String value is null, and this should be filtered out before going
into the StringCache because it's obviously useless. I could make the code a
little bit more defensive, but this should not be needed.
Comment 3 william.barker 2004-12-15 02:57:55 UTC
(In reply to comment #2)
> I don't understand what causes the bug. Can you submit a better test case
> (similar code runs fine for me) ?

You could also get it from an unsupported encoding in toStringInternal.
Comment 4 Erik Pragt 2004-12-15 10:18:55 UTC
(In reply to comment #1)
> Do you see this in conf/catalina.properties:
> tomcat.util.buf.StringCache.byte.enabled=true ?
> So you can easily work around the problem.

Done, which works, but causes other problems like getting 'white pages' on some
GET requests.

I found out how the problem arrised. When looking in server.xml, was a connector
entry:

<Connector URIEncoding="null" enableLookups="true" port="9000" redirectPort="-1"
backlog="10" disableUploadTimeout="false">
</Connector>

As you can see, the URIUncoding is null. I don't know what it means excactly,
but I didn't put it there. I used the admin tool to add the connector. I'd like
to try to reproduce the problem, but my Admin tool doesn't work anymore. I
cannot collapse items (I don't know if I should file this as another bug report,
but I cannot say more than: my menuitems don't collapse anymore after adding a
new service...)

After removing the URIencoding, everything is working fine again, even after
re-enabling the StringCache.
Comment 5 Erik Pragt 2004-12-15 10:21:22 UTC
(In reply to comment #2)
> I don't understand what causes the bug. Can you submit a better test case
> (similar code runs fine for me) ?
> 
> It's really odd that you're getting an exception there, because it can only
> happen if the String value is null, and this should be filtered out before going
> into the StringCache because it's obviously useless. I could make the code a
> little bit more defensive, but this should not be needed.

ps, please leave the code unchanged. I like the webserver to not when something
is not right, instead of eg. continue-ing the webserver and maybe causing some
servere errors elsewhere, while not knowing what caused the problem.
Comment 6 Erik Pragt 2004-12-15 10:37:31 UTC
(In reply to comment #5)

> ps, please leave the code unchanged. I like the webserver to not when something
> is not right, instead of eg. continue-ing the webserver and maybe causing some
> servere errors elsewhere, while not knowing what caused the problem.
> 
[type]

I like the webserver to not when... = I like the webserver to 'crash' when...
Comment 7 Remy Maucherat 2004-12-15 12:02:45 UTC
Then the cause of the problem is what Bill said: an invalid encoding is used for
the String. I think I should be able to reproduce the issue now, and I'll try to
see if I can improve the situation.

The admin works again in 5.5.6, BTW. I don't know if it handles connectors
correctly or not, as I didn't use it at all in the 5.5 branch.
Comment 8 Remy Maucherat 2004-12-15 12:57:13 UTC
I tried the admin webapp, and while it's probably not perfect for connector
handling, it didn't save bad information (such as URIEncoding="null"), and
Tomcat operated fine after a restart.