Using Lift embedded in Jetty 9.4.9

69 views
Skip to first unread message

Dan Gravell

unread,
Apr 10, 2018, 10:01:18 AM4/10/18
to Lift
I noticed I needed to do something similar to https://shadowfiend.posthaven.com/notes-on-deploying-lift-apps-to-glassfish to get continuations working in Jetty 9.4.9.

My resulting web.xml is:

<?xml version="1.0" encoding="ISO-8859-1"?>

<filter>
  <filter-name>LiftFilter</filter-name>
  <filter-class>net.liftweb.http.LiftFilter</filter-class>
  <async-supported>true</async-supported>
</filter>
 

<filter-mapping>
  <filter-name>LiftFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

</web-app>

I still see a lot of old-school web.xmls around on the web. Am I being *too* cool for school here?

Dan

Donald McLean

unread,
Apr 10, 2018, 10:20:17 AM4/10/18
to liftweb
That's nearly identical to mine (last modified November 2010).

I'm missing the <async-supported> - should I have that?
> --
> --
> Lift, the simply functional web framework: http://liftweb.net
> Code: http://github.com/lift
> Discussion: http://groups.google.com/group/liftweb
> Stuck? Help us help you:
> https://www.assembla.com/wiki/show/liftweb/Posting_example_code
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to liftweb+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Family photographs are a critical legacy for
ourselves and our descendants. Protect that
legacy with a digital backup and recovery plan.

Dan Gravell

unread,
Apr 10, 2018, 10:33:20 AM4/10/18
to Lift
I found that when Jetty starts it instantiates a FilterHolder which holds the Lift filter. This has an attribute _asyncSupported. For me, I noticed StandardDescriptorProcessor.visitFilter was setting this to false. I think this means no continuations.

Dan

Antonio Salazar Cardozo

unread,
Apr 13, 2018, 2:42:23 PM4/13/18
to Lift
You definitely want asyncSupported, otherwise most servlet 3.0 containers will tie up
a thread for each of your comet long-poll requests. That usually leads to a situation where
new page loads are blocked after a certain point because comet requests are tying up
threads that can't be used to serve regular pages.

Async turns on continuations as Dan mentions, which means the comet long-polls don't
take up any threads unless they're actively sending something back to the client.
Thanks,
Anotnio

Tim Nelson

unread,
Apr 14, 2018, 4:48:25 AM4/14/18
to Lift
According to this: https://stackoverflow.com/a/20644532, async-supported was added in Jetty8, but the default was `true`. WIth Jetty 9 they changed the default to `false`. 

I don't use a web.xml at all, I configure everything in Scala. I'm trying to figure out how to add it that way and if our site is even using continuations right now. I guess it pays to read those release notes.

Tim

Matt Farmer

unread,
Apr 14, 2018, 9:39:46 AM4/14/18
to lif...@googlegroups.com
This may explain some performance surprises I had on a small application/ server recently. Heh.

Matt Farmer

unread,
Apr 14, 2018, 9:43:19 AM4/14/18
to Lift
I just checked - our giter8 templates have async-supported set to true, so anyone who has been using those has the correct settings. And my app that I was having a problem with does not :facepalm:

To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+unsubscribe@googlegroups.com.

Tim Nelson

unread,
Apr 15, 2018, 6:19:24 AM4/15/18
to Lift
In case anyone else doesn't use a web.xml and only uses code, it seems to default to being enabled.

I have code like this:

val context = new WebAppContext(webappPath, "/")
context.addFilter(
  classOf[LiftFilter],
  "/*",
  EnumSet.allOf(classOf[DispatcherType])
)


If you capture the return value of the `addFilter` function:

val holder = context.addFilter(
  classOf[LiftFilter],
  "/*",
  EnumSet.allOf(classOf[DispatcherType])
)

logger.info("async: " + holder.isAsyncSupported)

You can see that `isAsyncSupported` returns `true`.

This is with Jetty 9.4.8.v20171121 and 9.4.9.v20180320

Tim
Reply all
Reply to author
Forward
0 new messages