我正在使用Jetty 9运行SolR。它工作正常。
我有以下配置:1个Web服务器(IIS),1个solr Server(Jetty)。
为了优化带宽使用,我想在这两台服务器之间启用GZIP压缩。
我尝试将其添加到jetty/etc/webdefault.xml
:
<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,text/css,application/javascript,application/json,image/svg+xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>GzipFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
我收到以下错误:
2013-06-19 11:16:19.534:WARN:oejuc.AbstractLifeCycle:main: FAILED GzipFilter: javax.servlet.UnavailableException: org.eclipse.jetty.servlets.GzipFilter
javax.servlet.UnavailableException: org.eclipse.jetty.servlets.GzipFilter
at org.eclipse.jetty.servlet.Holder.doStart(Holder.java:108)
at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:91)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:743)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:279)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1312)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:722)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:490)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:274)
at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:193)
at org.eclipse.jetty.util.component.ContainerLifeCycle.updateBeans(ContainerLifeCycle.java:713)
at org.eclipse.jetty.server.handler.HandlerCollection.setHandlers(HandlerCollection.java:89)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.setHandlers(ContextHandlerCollection.java:165)
at org.eclipse.jetty.server.handler.HandlerCollection.addHandler(HandlerCollection.java:155)
at org.eclipse.jetty.deploy.bindings.StandardDeployer.processBinding(StandardDeployer.java:41)
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:495)
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:175)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)
at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:600)
at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:528)
at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:313)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:145)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:557)
at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:232)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:108)
at org.eclipse.jetty.server.Server.start(Server.java:346)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:90)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58)
at org.eclipse.jetty.server.Server.doStart(Server.java:294)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1233)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jetty.start.Main.invokeMain(Main.java:453)
at org.eclipse.jetty.start.Main.start(Main.java:595)
at org.eclipse.jetty.start.Main.main(Main.java:96)
2013-06-19 11:16:19.534:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@3dada196{/,file:/E:/Solr/jetty-9/webapps/ROOT/,STARTING}{E:\Solr\jetty-9\webapps\ROOT}
javax.servlet.UnavailableException: org.eclipse.jetty.servlets.GzipFilter
at org.eclipse.jetty.servlet.Holder.doStart(Holder.java:108)
at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:91)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:743)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:279)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1312)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:722)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:490)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:274)
at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:193)
at org.eclipse.jetty.util.component.ContainerLifeCycle.updateBeans(ContainerLifeCycle.java:713)
at org.eclipse.jetty.server.handler.HandlerCollection.setHandlers(HandlerCollection.java:89)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.setHandlers(ContextHandlerCollection.java:165)
at org.eclipse.jetty.server.handler.HandlerCollection.addHandler(HandlerCollection.java:155)
at org.eclipse.jetty.deploy.bindings.StandardDeployer.processBinding(StandardDeployer.java:41)
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:495)
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:175)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)
at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:600)
at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:528)
at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:313)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:145)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:557)
at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:232)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:108)
at org.eclipse.jetty.server.Server.start(Server.java:346)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:90)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58)
at org.eclipse.jetty.server.Server.doStart(Server.java:294)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1233)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jetty.start.Main.invokeMain(Main.java:453)
at org.eclipse.jetty.start.Main.start(Main.java:595)
at org.eclipse.jetty.start.Main.main(Main.java:96)
有人有想法吗?
答案 0 :(得分:8)
通常,您将GzipFilter添加到您的网络应用WEB-INF/web.xml
,并将jetty-servlets.jar
添加到您的WEB-INF/lib
目录中。
但是,可以将它配置在顶级jetty服务器级别。
对于初学者,您获得的错误表明您的服务器类路径中不存在jetty-servlets.jar。
要对此进行测试,请从独立的jetty-distribution中运行以下命令。
$ java -jar start.jar --version
Active Options: [Server, annotations, client, ext, jaas, jmx, jndi, jndi.demo, jsp, plus, resources, rewrite, websocket]
Version Information on 36 entries in the classpath.
Note: order presented here is how they would appear on the classpath.
changes to the OPTIONS=[option,option,...] command line option will be reflected here.
0: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-xml-9.0.3.v20130506.jar
1: 3.0.0.v201112011016 | ${jetty.home}/lib/servlet-api-3.0.jar
2: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-http-9.0.3.v20130506.jar
3: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-continuation-9.0.3.v20130506.jar
4: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-server-9.0.3.v20130506.jar
5: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-security-9.0.3.v20130506.jar
6: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-servlet-9.0.3.v20130506.jar
7: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-webapp-9.0.3.v20130506.jar
8: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-deploy-9.0.3.v20130506.jar
9: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-annotations-9.0.3.v20130506.jar
10: 1.1.0.v201108011116 | ${jetty.home}/lib/annotations/javax.annotation-1.1.0.v201108011116.jar
11: 3.1.0.v200803061910 | ${jetty.home}/lib/annotations/org.objectweb.asm-3.1.0.v200803061910.jar
12: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-client-9.0.3.v20130506.jar
13: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-jaas-9.0.3.v20130506.jar
14: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-jmx-9.0.3.v20130506.jar
15: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-jndi-9.0.3.v20130506.jar
16: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-plus-9.0.3.v20130506.jar
17: 1.1.0.v201105071233 | ${jetty.home}/lib/jndi/javax.activation-1.1.0.v201105071233.jar
18: 1.4.1.v201005082020 | ${jetty.home}/lib/jndi/javax.mail.glassfish-1.4.1.v201005082020.jar
19: 1.1.1 | ${jetty.home}/lib/jndi/javax.transaction-1.1.1.v201105210645.jar
20: 9.0.3.v20130506 | ${jetty.home}/lib/jndi.demo/test-mock-resources-9.0.3.v20130506.jar
21: 2.2.0.v201303151357 | ${jetty.home}/lib/jsp/com.sun.el-2.2.0.v201303151357.jar
22: 2.2.0.v201303151357 | ${jetty.home}/lib/jsp/javax.el-2.2.0.v201303151357.jar
23: 1.2.0.v201105211821 | ${jetty.home}/lib/jsp/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar
24: 2.2.0.v201112011158 | ${jetty.home}/lib/jsp/javax.servlet.jsp-2.2.0.v201112011158.jar
25: 2.2.2.v201112011158 | ${jetty.home}/lib/jsp/org.apache.jasper.glassfish-2.2.2.v201112011158.jar
26: 1.2.0.v201112081803 | ${jetty.home}/lib/jsp/org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar
27: 3.8.2.v20130121-145325 | ${jetty.home}/lib/jsp/org.eclipse.jdt.core-3.8.2.v20130121.jar
28: (dir) | ${jetty.home}/resources
29: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-rewrite-9.0.3.v20130506.jar
30: 9.0.3.v20130506 | ${jetty.home}/lib/websocket/websocket-api-9.0.3.v20130506.jar
31: 9.0.3.v20130506 | ${jetty.home}/lib/websocket/websocket-common-9.0.3.v20130506.jar
32: 9.0.3.v20130506 | ${jetty.home}/lib/websocket/websocket-server-9.0.3.v20130506.jar
33: 9.0.3.v20130506 | ${jetty.home}/lib/websocket/websocket-servlet-9.0.3.v20130506.jar
34: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-util-9.0.3.v20130506.jar
35: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-io-9.0.3.v20130506.jar
这将显示服务器类路径,如您所见,标准分发默认情况下没有jetty-servlets.jar
可用。不过start.config
中包含的start.jar
OPTION
预定义为servlets
注意:要查看您可以使用的OPTIONS
列表
$ java -jar start.jar --list-options
注意:要查看start.config
正在使用的start.jar
。
$ java -jar start.jar --list-config
最后,要使用此信息,我们只需编辑servlets
即可在每次启动jetty时提供OPTION
start.ini
。
$ echo "OPTIONS=servlets" >> start.ini
$ java -jar start.jar --version
Active Options: [Server, annotations, client, ext, jaas, jmx, jndi, jndi.demo, jsp, plus, resources, rewrite, servlets, websocket]
Version Information on 37 entries in the classpath.
Note: order presented here is how they would appear on the classpath.
changes to the OPTIONS=[option,option,...] command line option will be reflected here.
0: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-xml-9.0.3.v20130506.jar
1: 3.0.0.v201112011016 | ${jetty.home}/lib/servlet-api-3.0.jar
2: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-http-9.0.3.v20130506.jar
3: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-continuation-9.0.3.v20130506.jar
4: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-server-9.0.3.v20130506.jar
5: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-security-9.0.3.v20130506.jar
6: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-servlet-9.0.3.v20130506.jar
7: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-webapp-9.0.3.v20130506.jar
8: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-deploy-9.0.3.v20130506.jar
9: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-annotations-9.0.3.v20130506.jar
10: 1.1.0.v201108011116 | ${jetty.home}/lib/annotations/javax.annotation-1.1.0.v201108011116.jar
11: 3.1.0.v200803061910 | ${jetty.home}/lib/annotations/org.objectweb.asm-3.1.0.v200803061910.jar
12: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-client-9.0.3.v20130506.jar
13: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-jaas-9.0.3.v20130506.jar
14: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-jmx-9.0.3.v20130506.jar
15: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-jndi-9.0.3.v20130506.jar
16: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-plus-9.0.3.v20130506.jar
17: 1.1.0.v201105071233 | ${jetty.home}/lib/jndi/javax.activation-1.1.0.v201105071233.jar
18: 1.4.1.v201005082020 | ${jetty.home}/lib/jndi/javax.mail.glassfish-1.4.1.v201005082020.jar
19: 1.1.1 | ${jetty.home}/lib/jndi/javax.transaction-1.1.1.v201105210645.jar
20: 9.0.3.v20130506 | ${jetty.home}/lib/jndi.demo/test-mock-resources-9.0.3.v20130506.jar
21: 2.2.0.v201303151357 | ${jetty.home}/lib/jsp/com.sun.el-2.2.0.v201303151357.jar
22: 2.2.0.v201303151357 | ${jetty.home}/lib/jsp/javax.el-2.2.0.v201303151357.jar
23: 1.2.0.v201105211821 | ${jetty.home}/lib/jsp/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar
24: 2.2.0.v201112011158 | ${jetty.home}/lib/jsp/javax.servlet.jsp-2.2.0.v201112011158.jar
25: 2.2.2.v201112011158 | ${jetty.home}/lib/jsp/org.apache.jasper.glassfish-2.2.2.v201112011158.jar
26: 1.2.0.v201112081803 | ${jetty.home}/lib/jsp/org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar
27: 3.8.2.v20130121-145325 | ${jetty.home}/lib/jsp/org.eclipse.jdt.core-3.8.2.v20130121.jar
28: (dir) | ${jetty.home}/resources
29: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-rewrite-9.0.3.v20130506.jar
30: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-servlets-9.0.3.v20130506.jar
31: 9.0.3.v20130506 | ${jetty.home}/lib/websocket/websocket-api-9.0.3.v20130506.jar
32: 9.0.3.v20130506 | ${jetty.home}/lib/websocket/websocket-common-9.0.3.v20130506.jar
33: 9.0.3.v20130506 | ${jetty.home}/lib/websocket/websocket-server-9.0.3.v20130506.jar
34: 9.0.3.v20130506 | ${jetty.home}/lib/websocket/websocket-servlet-9.0.3.v20130506.jar
35: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-util-9.0.3.v20130506.jar
36: 9.0.3.v20130506 | ${jetty.home}/lib/jetty-io-9.0.3.v20130506.jar
此时您可以看到jetty-servlets.jar
现在在服务器端可用。 (上面输出中的第30条)
答案 1 :(得分:0)
对于寻找答案的人来说,为什么帖子请求没有被压缩;默认情况下,过滤器仅压缩GET请求。添加
<init-param>
<param-name>methods</param-name>
<param-value>GET,POST</param-value>
</init-param>
压缩POST。