NullPointerException in Jetty when using Comet [Lift 2.0, Jetty 6.1.24]

51 views
Skip to first unread message

elsten software

unread,
Jan 5, 2011, 12:14:27 PM1/5/11
to Lift
Hi all, I'm trying to track down a hard-to-reproduce bug which appears
to occur a little while after using my Lift-based application.

I've experienced this exception just once and a customer has also
experienced it several times. Here's the stack trace (apologies for
the length of the trace but I'm not sure how long is long enough):

HTTP ERROR 500

Problem accessing /index.html. Reason:

INTERNAL_SERVER_ERROR
Caused by:

java.lang.NullPointerException
at org.mortbay.jetty.Request.getServerName(Request.java:1113)
at org.mortbay.jetty.Request.getServerPort(Request.java:1170)
at
net.liftweb.http.provider.servlet.HTTPRequestServlet.serverPort(HTTPRequestServlet.scala:
88)
at net.liftweb.http.Req$$anonfun$hostAndPath$1.apply(Req.scala:
397)
at net.liftweb.http.Req$$anonfun$hostAndPath$1.apply(Req.scala:
397)
at net.liftweb.common.Full.map(Box.scala:398)
at net.liftweb.http.Req.hostAndPath(Req.scala:397)
at net.liftweb.http.LiftSession$$anonfun$cometForHost
$1.apply(LiftSession.scala:344)
at net.liftweb.http.LiftSession$$anonfun$cometForHost
$1.apply(LiftSession.scala:343)
at scala.List.filter(List.scala:859)
at net.liftweb.http.LiftSession.cometForHost(LiftSession.scala:
343)
at net.liftweb.http.LiftRules$$anonfun$10.apply(LiftRules.scala:
173)
at net.liftweb.http.LiftRules$$anonfun$10.apply(LiftRules.scala:
170)
at net.liftweb.http.LiftRules$.net$liftweb$http$LiftRules$
$_getLiftSession(LiftRules.scala:161)
at net.liftweb.http.LiftRules$$anonfun$8.apply(LiftRules.scala:
120)
at net.liftweb.http.LiftRules$$anonfun$8.apply(LiftRules.scala:
120)
at net.liftweb.http.LiftServlet.getLiftSession(LiftServlet.scala:
76)
at net.liftweb.http.LiftServlet.doService(LiftServlet.scala:186)
at net.liftweb.http.LiftServlet$$anonfun$doIt
$1$1.apply(LiftServlet.scala:86)
at net.liftweb.http.LiftServlet$$anonfun$doIt
$1$1.apply(LiftServlet.scala:86)
at net.liftweb.util.TimeHelpers$class.calcTime(TimeHelpers.scala:
326)
at net.liftweb.util.Helpers$.calcTime(Helpers.scala:34)
at net.liftweb.util.TimeHelpers$class.logTime(TimeHelpers.scala:
335)
at net.liftweb.util.Helpers$.logTime(Helpers.scala:34)
at net.liftweb.http.LiftServlet.doIt$1(LiftServlet.scala:85)
at net.liftweb.http.LiftServlet.service(LiftServlet.scala:96)
at net.liftweb.http.provider.HTTPProvider$$anonfun$service
$3.apply(HTTPProvider.scala:61)
at net.liftweb.http.provider.HTTPProvider$$anonfun$service
$3.apply(HTTPProvider.scala:61)
at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71)
at net.liftweb.http.URLRewriter$.doWith(Req.scala:618)
at net.liftweb.http.provider.HTTPProvider
$class.service(HTTPProvider.scala:60)
at net.liftweb.http.LiftFilter.service(LiftServlet.scala:586)
at net.liftweb.http.provider.servlet.ServletFilterProvider
$class.protected$service(ServletFilterProvider.scala:67)
at net.liftweb.http.LiftFilter.protected$service(LiftServlet.scala:
586)
at net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun
$doFilter$1$$anonfun$apply$1.apply(ServletFilterProvider.scala:67)
at net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun
$doFilter$1$$anonfun$apply$1.apply(ServletFilterProvider.scala:62)
at net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$9$$anonfun
$apply$10$$anonfun$apply$11$$anonfun$apply$12.apply(Vars.scala:335)
at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71)
at net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$9$$anonfun
$apply$10$$anonfun$apply$11.apply(Vars.scala:334)
at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71)
at net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$9$$anonfun
$apply$10.apply(Vars.scala:333)
at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71)
at net.liftweb.http.CoreRequestVarHandler$$anonfun$apply
$9.apply(Vars.scala:332)
at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71)
at net.liftweb.http.CoreRequestVarHandler$class.apply(Vars.scala:
331)
at net.liftweb.http.RequestVarHandler$.apply(Vars.scala:250)
at net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun
$doFilter$1.apply(ServletFilterProvider.scala:61)
at net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun
$doFilter$1.apply(ServletFilterProvider.scala:61)
at net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$9$$anonfun
$apply$10$$anonfun$apply$11$$anonfun$apply$12.apply(Vars.scala:335)
at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71)
at net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$9$$anonfun
$apply$10$$anonfun$apply$11.apply(Vars.scala:334)
at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71)
at net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$9$$anonfun
$apply$10.apply(Vars.scala:333)
at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71)
at net.liftweb.http.CoreRequestVarHandler$$anonfun$apply
$9.apply(Vars.scala:332)
at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71)
at net.liftweb.http.CoreRequestVarHandler$class.apply(Vars.scala:
331)
at net.liftweb.http.TransientRequestVarHandler$.apply(Vars.scala:
254)
at net.liftweb.http.provider.servlet.ServletFilterProvider
$class.doFilter(ServletFilterProvider.scala:60)
at net.liftweb.http.LiftFilter.doFilter(LiftServlet.scala:586)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1157)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
388)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
182)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
765)
at
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
542)
at org.mortbay.jetty.HttpConnection
$RequestHandler.headerComplete(HttpConnection.java:926)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:
212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:
404)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
410)
at org.mortbay.thread.QueuedThreadPool
$PoolThread.run(QueuedThreadPool.java:582)

It's happened on two separate pages of my app, although both share the
same comet actor. I assume it's related to comet due to the mention of
comet in the stack trace.

It appears to occur after a while of having the application running.
It has definitely occurred on page load, and I think it may also have
occurred as a result of a XHR call.

The NPE is caused when a member of jetty.Request, _uri, is referenced
in getServerName(). It looks like _uri is nullified by the recycle()
method, which is called from jetty.HttpConnection when the request/
response is complete (however, could continuations be affecting
this?). There is also a setter for _uri, but it appears this isn't
being called from a quick code review.

I haven't asked on the Jetty lists yet, which might be sensible, I
guess I wanted to move down the app stack gradually to understand what
Lift is doing with the jetty.Request at this point and see if anyone
else had experienced this. I could try to upgrade Lift and Jetty
versions but as I cannot reproduce I cannot be sure of whether doing
so has fixed the bug. I wanted to see if anyone had seen anything
similar or had any experience in this area.

Thanks!

David Pollak

unread,
Jan 5, 2011, 6:12:44 PM1/5/11
to lif...@googlegroups.com
Please upgrade to Lift 2.2

If that does not address the issue, if you can put together a reproducible example, that would be helpful.

Net-net looking at the stack trace, it's happening during a normal HTTP request/response cycle (no continuations visible) and it seems very reasonable for Lift to ask for the name of the server and the port of the request during the handling of a normal HTTP request.


--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Blog: http://goodstuff.im
Surf the harmonics

elsten software

unread,
Jan 6, 2011, 10:26:03 AM1/6/11
to Lift
Thanks David. I have upgraded to Lift 2.2 and downgraded Jetty to
6.1.22. I'll test on that, and if the problem comes up again I'll
hopefully be able to create something more reproducible.

Thanks,
Dan

On Jan 5, 11:12 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@googlegroups.com >
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/liftweb?hl=en.
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
Reply all
Reply to author
Forward
0 new messages