0
votes

The documentation for RESTEasy says that in addition to annotating your server endpoint with the "@GZIP" annotation, you need to make a file called "javax.ws.rs.ext.Providers" available in the classpath of your runtime environment and include the classname "org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor" in the file.

I've done all of the above, but the response coming back from the server is NOT compressed, even though the response "Content-Encoding" header is "gzip" (i.e. the response body is plain text/json, despite what the header says).

The javax.ws.rs.ext.Providers file is definitely in my WEB-INF/classes folder in the .war and in the app folder when deployed to Tomcat, but RESTEasy is ignoring it.

So, is there something I'm missing? Does anyone have this working?

EDIT: Okay, I discovered that RESTEasy is actually looking for the full path "META-INF/services/javax.ws.rs.ext.Providers", so I had to create that folder path plus file in my resources folder. And yes, that is confusing, since there is already a META-INF folder in the .war archive; however, putting the "services" sub-folder and "javax.ws.rs.ext.Providers" file in that META-INF folder does NOT work. Sigh.

1
Did you use a packet sniffer to determine that is not compressed?Namphibian
Yes, I used TCPMon to examine the traffic and determined that the traffic was uncompressed JSON, despite the fact that the HTTP header claims it was gzip.Roy Wood

1 Answers

3
votes

I got it working & I hope this will help you in resolving the same. The trick is to have this within the WEB-INF/classes. What I did was to have javax.ws.rs.ext.Providers in the location: /WEB-INF/classes/META-INF/services & voila it started working.

The reason for this is to do with the classloader reference that it has in the code trying to search for this file. I am using tomcat. But if you are using JBoss or any other application / web server, the classloading mechanisms might vary based on the container implementation. So figure out which is the best location for your server.