Thursday, November 21, 2013

How to get gzip working for Jetty 8 and Solr

If you're getting the following error message in the solr.log file:

java.lang.ClassNotFoundException: org.eclipse.jetty.servlets.GzipFilter

Try doing the following:

Edit /opt/solr/solr-webapp/webapp/WEB-INF/web.xml and put the following in it:


<web-app ... >


<filter>
      <filter-name>GzipFilter</filter-name>
      <filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class>
      <init-param>
        <param-name>mimeTypes</param-name>  
        <param-value>text/html,text/plain,text/xml,application/xhtml+xml,application/xml,text/css,application/javascript,image/svg+xml,application/json,application/xml; charset=UTF-8</param-value>
      </init-param>
    </filter>
    <filter-mapping>
      <filter-name>GzipFilter</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>

If you don't have a jetty-servlets*.jar file, then download it from http://mvnrepository.com/artifact/org.eclipse.jetty/jetty-servlets and put it in /opt/solr/lib

Restart jetty:

sudo /sbin/service jetty restart

If solr doesn't start up, check the /opt/solr/logs/solr.log file.

No comments: