我正在尝试将 Jetty 配置为 http 和 https 的代理。我已经下载了两个不同版本的码头,但我都遇到了同样的问题。
我目前使用的版本是:jetty-distribution-8.1.8.v20121106 在 CentOs 6.2 上运行。
解压 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
码头定期启动。我可以通过以下方式访问它:
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 协议 [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 上的代理时,码头失败并出现以下异常:
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。要执行码头,我使用命令: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
谢谢