PaxWeb: Jetty and GZipHandler

190 views
Skip to first unread message

Jérémie Brébec

unread,
Jun 29, 2017, 4:18:35 AM6/29/17
to OPS4J
Hi,

With Jetty v9.3 (with PaxWeb 6.0.3), the GZipFilter is marked as obsolete. As Jetty is really verbose about this deprecation, I am trying to upgrade my application to remove all registration of the GZipFilter and use instead a global GZipHandler.

However, I didn't succed to configure PaxWeb with this "HandlerWrapper" in jetty.xml :
  • The official way is to call "Server.insertHandler" which create a chain of HandlerWrapper. However, PaxWeb seems to suppose that the first handlerwrapper is his own "JettyServerHandlerCollection", and I have a lot of exception ("java.lang.IllegalStateException: STARTED" on each registratrion (cf [1]), and a ClassCastException when the bundle is stopped)
  • If I call "getHandler().addHandler(..)", this doesn't work either : the GZiphandler is either not call or throw a NPE as it doesn't have a child handler
How can I use this Handler with PaxWeb ? Moreover, is there an equivalent of the "jetty.xml" for undertow ?

Thanks !


[1] 
2017-06-28T18:03:58,102 | ERROR | Start Level: Equinox Container: 052d47d4-8713-4018-89e6-d2027a5ad69f | WebApplication                   | 234 - org.ops4j.pax.web.pax-web-extender-whiteboard - 6.0.3 | Registration skipped for [ServletWebElement{mapping=DefaultServletMapping{httpContextId=null,urlPatterns=null,initParams={},servlet=xxx.web.redirect.RedirectServlet@5477a25b, alias=/redirect, servletNameredirect}}] due to error during registration
java.lang.IllegalStateException: STARTED
at org.eclipse.jetty.server.handler.HandlerWrapper.setHandler(HandlerWrapper.java:85) [206:org.eclipse.jetty.server:9.3.14.v20161028]
at org.eclipse.jetty.servlet.ServletContextHandler.<init>(ServletContextHandler.java:166) [207:org.eclipse.jetty.servlet:9.3.14.v20161028]
at org.eclipse.jetty.servlet.ServletContextHandler.<init>(ServletContextHandler.java:128) [207:org.eclipse.jetty.servlet:9.3.14.v20161028]
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.<init>(HttpServiceContext.java:116) [235:org.ops4j.pax.web.pax-web-jetty:6.0.3]
at org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper.addContext(JettyServerWrapper.java:290) [235:org.ops4j.pax.web.pax-web-jetty:6.0.3]
at org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper.getOrCreateContext(JettyServerWrapper.java:209) [235:org.ops4j.pax.web.pax-web-jetty:6.0.3]
at org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper.getOrCreateContext(JettyServerWrapper.java:190) [235:org.ops4j.pax.web.pax-web-jetty:6.0.3]
at org.ops4j.pax.web.service.jetty.internal.JettyServerImpl.addServlet(JettyServerImpl.java:324) [235:org.ops4j.pax.web.pax-web-jetty:6.0.3]
at org.ops4j.pax.web.service.jetty.internal.ServerControllerImpl$Started.addServlet(ServerControllerImpl.java:289) [235:org.ops4j.pax.web.pax-web-jetty:6.0.3]
at org.ops4j.pax.web.service.jetty.internal.ServerControllerImpl.addServlet(ServerControllerImpl.java:110) [235:org.ops4j.pax.web.pax-web-jetty:6.0.3]
at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:239) [237:org.ops4j.pax.web.pax-web-runtime:6.0.3]

Achim Nierbeck

unread,
Jun 30, 2017, 4:54:02 PM6/30/17
to op...@googlegroups.com
Hi, 

right now I'm not sure if that is a bug or just a "misconfiguration". 
Though right now I'm running low on time and energy to take a closer look. 
If in doubt, just open a Jira issue so it won't be forgotten. 
Unfortunately I can't tell how fast I'm able to take a look at it. 

regarding comparable thing to jetty.xml for undertow. I'm not even sure such a thing exists for undertow (but I'm not to deep into that so that isn't a measurment ;) ) 
Might want to check the existing issues, if there already is a fix for this or open issue, if not don't hesitate to create another one :) 

regards, Achim 


regards, Achim 


--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master 

Eric Lessard

unread,
Aug 10, 2017, 1:44:10 AM8/10/17
to OPS4J
Any update on this or work around available? We're running into a similar problem and are looking at options to compress our static content.

Thanks!

Achim Nierbeck

unread,
Aug 30, 2017, 12:20:23 AM8/30/17
to op...@googlegroups.com
Hi, 

if this is an issue for you please file a bug in our Jira. 

Thanks, Achim 

2017-08-10 7:44 GMT+02:00 Eric Lessard <lessar...@gmail.com>:
Any update on this or work around available? We're running into a similar problem and are looking at options to compress our static content.

Thanks!
--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jérémie Brébec

unread,
Jan 16, 2019, 8:20:25 AM1/16/19
to OPS4J
Hello,

I reopen this old thread, but has anyone a working example of a GzipHandler with PaxWeb (7.2.5) ?

Thanks !


Le mercredi 30 août 2017 06:20:23 UTC+2, Achim Nierbeck a écrit :
Hi, 

if this is an issue for you please file a bug in our Jira. 

Thanks, Achim 
2017-08-10 7:44 GMT+02:00 Eric Lessard <lessar...@gmail.com>:
Any update on this or work around available? We're running into a similar problem and are looking at options to compress our static content.

Thanks!

--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Jean-Baptiste Onofré

unread,
Jan 16, 2019, 8:31:12 AM1/16/19
to op...@googlegroups.com

Not with recent 7.2.x version.

I think it deserves a unit test ;)

Regards
JB

pEpkey.asc

Grzegorz Grzybek

unread,
Jan 16, 2019, 8:52:56 AM1/16/19
to op...@googlegroups.com
Hello

There are 40 unresolved issues in https://ops4j1.jira.com/projects/PAXWEB/summary/statistics - I didn't see any about gzip.
Could you refresh my memory? :)

regards
Grzegorz Grzybek

Jérémie Brébec

unread,
Jan 16, 2019, 9:39:49 AM1/16/19
to OPS4J
I don't know if it's an issue in paxweb or just a configuration difficult to write.

I want to activate a GzipHandler in order to gzip contents served by my servlets. The old Jetty GzipFilter is deprecated and do nothing.

This Handler is a HandlerWrapper, it hooks the handler chain in order to provider a wrapped response (which do the gzip encoding). I am not able to configure such handlers in the jetty.xml (PaxWeb-Jetty assumes at several location that the first handler is the JettyServerHandlerCollection and I can't replace it with the GzipHandler or any other HandlerWrapper without issues/exceptions).

I have a working solution, but it necessites some change in the codebase. However, I suppose I am not the only one who want to use gzip and paxweb, so I don't know if I am missing something :-)

Jérémie Brébec

unread,
Jan 16, 2019, 9:46:19 AM1/16/19
to OPS4J
I have attached the patch I use. With this patch, I can use the GzipHandler with this configuration :

<!-- GZIP -->
 
<Get id="OldHandler" name="handler"/>

 
<Set name="handler">
   
<New id="GzipHandler" class="org.eclipse.jetty.server.handler.gzip.GzipHandler">
     
<Set name="handler">
       
<Ref id="OldHandler"/>
     
</Set>
   
</New>
 
</Set>
HandlerWrapper-support.patch

Grzegorz Grzybek

unread,
Jan 16, 2019, 9:53:12 AM1/16/19
to op...@googlegroups.com
Hmm, it deserves PAXWEB jira issue.

We should either allow it to be configured in etc/jetty.xml or just enable (true/false) it in etc/org.ops4j.pax.web.cfg.
But I don't think I'll fix it today ;)

regards
Grzegorz Grzybek

Jean-Baptiste Onofré

unread,
Jan 16, 2019, 9:55:56 AM1/16/19
to op...@googlegroups.com

As it's a jetty handler, I think it's cleaner to keep it in jetty.xml.

@Jérémie: can you please create the Jira ? I will fix that quickly.

Regards

JB

pEpkey.asc

Jérémie Brébec

unread,
Jan 16, 2019, 10:12:14 AM1/16/19
to OPS4J
I have created this ticket: https://ops4j1.jira.com/browse/PAXWEB-1189

Thanks !
Reply all
Reply to author
Forward
0 new messages