我正在尝试将Jetty配置为http和https的代理。 我已经下载了两个不同版本的码头,但我遇到了同样的问题。
我目前使用的版本是:在CentOs 6.2上运行的jetty-distribution-8.1.8.v20121106。
解压缩tar.gz后,我修改了start.ini文件,添加了etc / jetty-proxy.xml 到配置文件列表:
#etc/jetty-jmx.xml
etc/jetty.xml
<b>etc/jetty-proxy.xml</b>
etc/jetty-annotations.xml
etc/jetty-ssl.xml
# etc/jetty-requestlog.xml
etc/jetty-deploy.xml
#etc/jetty-overlay.xml
etc/jetty-webapps.xml
etc/jetty-contexts.xml
etc/jetty-testrealm.xml
Jetty定期开始。我可以访问它:
http://localhost:8080/
https://localhost:8443/
读取日志文件似乎已在端口8080,8443和8888上启动了三个抽象连接器:
2012-12-04 12:40:03.400:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080 2012-12-04 12:40:03.666:INFO:oejus.SslContextFactory:Enabled Protocols [SSLv2Hello, SSLv3, TLSv1] of [SSLv2Hello, SSLv3, TLSv1] 2012-12-04 12:40:03.668:INFO:oejs.AbstractConnector:Started SslSelectChannelConnector@0.0.0.0:8443 2012-12-04 12:40:03.668:INFO:oejs.Server:jetty-8.1.8.v20121106 2012-12-04 12:40:03.732:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8888
当我将浏览器配置为访问端口8888上的代理时,jetty会失败并出现以下异常:
2012-12-04 12:40:13.463:WARN:oejs.ServletHandler:Error for /search
java.lang.NoClassDefFoundError: org/eclipse/jetty/client/HttpExchange
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.newInstance0(Class.java:326)
at java.lang.Class.newInstance(Class.java:308)
at org.eclipse.jetty.servlet.ServletHolder.newInstance(ServletHolder.java:941)
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:501)
at org.eclipse.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:402)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:642)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:662)
Caused by:
java.lang.ClassNotFoundException: org.eclipse.jetty.client.HttpExchange
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
...
我已经验证文件夹$ JETTY_HOME / lib包含jar文件:
jetty-client-8.1.8.v20121106.jar
包含类org.eclipse.jetty.client.HttpExchange。 要执行jetty,我使用命令: bin / jetty.sh start
命令bin / jetty.sh检查返回以下信息:
Checking arguments to Jetty:
JETTY_HOME = /home/dude/Downloads/jetty-distribution-8.1.8.v20121106
JETTY_CONF = /home/dude/Downloads/jetty-distribution-8.1.8.v20121106/etc/jetty.conf
JETTY_RUN = /tmp
JETTY_PID = /tmp/jetty.pid
JETTY_PORT =
JETTY_LOGS =
START_INI = /home/dude/Downloads/jetty-distribution-8.1.8.v20121106/start.ini
CONFIGS = --pre=etc/jetty-logging.xml
JAVA_OPTIONS = -Djetty.home=/home/dude/Downloads/jetty-distribution-8.1.8.v20121106-Djava.io.tmpdir=/tmp
JAVA = /data/dude/java/bin/java
CLASSPATH =
RUN_CMD = /data/dude/java/bin/java -Djetty.home=/home/dude/Downloads/jetty-distribution-8.1.8.v20121106 -Djava.io.tmpdir=/tmp -jar /home/dude/Downloads/jetty-distribution-8.1.8.v20121106/start.jar --pre=etc/jetty-logging.xml
Jetty running pid=15498
谢谢
答案 0 :(得分:2)
在start.ini添加客户端的OPTIONS中,代理环境要求客户端工件可用。与使用ProxyServlet相同,您需要在servlet web-inf / lib目录中拥有jetty-client及其依赖项。
无论如何,这将显示可能的选项以及在运行它时它在类路径中的作用。 start.jar真的只是帮助构建环境下的jetty运行。
java -jar start.jar --list-options
这将通过给出给定配置的示例命令行来向您显示当前的设置:
java -jar start.jar --dry-run
如需更多帮助,请查看:
java -jar start.jar --help
或者看这里: