1. Jetty 9.0.3 启动时的错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@kvm-guest jetty-9.0.3]# java -jar start.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/eclipse/jetty/start/Main : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: org.eclipse.jetty.start.Main. Program will exit.

原因:Jetty 9 需要 JVM 1.7 的支持(我原来的JVM是1.6) 
解决方案:使用Java 1.7即可。

2. 将jenkns.war复制到webapp目录后,启动Jetty,但jenkins访问出错,HTTP ERROR 503。 
启动和关闭Jetty的命令为:

1
2
3
[root@kvm-guest jetty-9.0.3]# java -jar start.jar -DSTOP.PORT=8881 -DSTOP.KEY=magic --daemon &
 
[root@kvm-guest jetty-9.0.3]# java -jar start.jar -DSTOP.PORT=8881 -DSTOP.KEY=magic --stop

在浏览器中访问时,遇到的错误信息如下:

1
2
3
4
5
HTTP ERROR: 503
Problem accessing /jenkins/. Reason:
Service Unavailable
------------
Powered by Jetty

查看Jetty的log中,可以看到如下的错误信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2013-05-21 14:33:31.265:WARN:oejuc.AbstractLifeCycle:main: FAILED org.eclipse.jetty.security.ConstraintSecurityHandler@70188b41: java.lang.IllegalStateException: No LoginService for org.eclipse.jetty.security.authentication.FormAuthenticator@790bb6f4 in org.eclipse.jetty.security.ConstraintSecurityHandler@70188b41
java.lang.IllegalStateException: No LoginService for org.eclipse.jetty.security.authentication.FormAuthenticator@790bb6f4 in org.eclipse.jetty.security.ConstraintSecurityHandler@70188b41
at org.eclipse.jetty.security.authentication.LoginAuthenticator.setConfiguration(LoginAuthenticator.java:67)
at org.eclipse.jetty.security.authentication.FormAuthenticator.setConfiguration(FormAuthenticator.java:131)
at org.eclipse.jetty.security.SecurityHandler.doStart(SecurityHandler.java:375)
at org.eclipse.jetty.security.ConstraintSecurityHandler.doStart(ConstraintSecurityHandler.java:457)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
...................
2013-05-21 14:33:31.267:WARN:oejuc.AbstractLifeCycle:main: FAILED org.eclipse.jetty.server.session.SessionHandler@5b5e91e5: java.lang.IllegalStateException: No LoginService for org.eclipse.jetty.security.authentication.FormAuthenticator@790bb6f4 in org.eclipse.jetty.security.ConstraintSecurityHandler@70188b41
java.lang.IllegalStateException: No LoginService for org.eclipse.jetty.security.authentication.FormAuthenticator@790bb6f4 in org.eclipse.jetty.security.ConstraintSecurityHandler@70188b41
at org.eclipse.jetty.security.authentication.LoginAuthenticator.setConfiguration(LoginAuthenticator.java:67)
at org.eclipse.jetty.security.authentication.FormAuthenticator.setConfiguration(FormAuthenticator.java:131)
...................
2013-05-21 14:33:31.268:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@729b9707{/jenkins,file:/tmp/jetty-0.0.0.0-8080-jenkins.war-_jenkins-any-/webapp/,STARTING}{/root/jetty-9.0.3/webapps.demo/jenkins.war}
java.lang.IllegalStateException: No LoginService for org.eclipse.jetty.security.authentication.FormAuthenticator@790bb6f4 in org.eclipse.jetty.security.ConstraintSecurityHandler@70188b41
at org.eclipse.jetty.security.authentication.LoginAuthenticator.setConfiguration(LoginAuthenticator.java:67)
at org.eclipse.jetty.security.authentication.FormAuthenticator.setConfiguration(FormAuthenticator.java:131)
at org.eclipse.jetty.security.SecurityHandler.doStart(SecurityHandler.java:375)
at org.eclipse.jetty.security.ConstraintSecurityHandler.doStart(ConstraintSecurityHandler.java:457)
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.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:90)

原因:Jetty 8.1.0之后对安全性有了一些要求,需要显示注明安全域(security realm)。 
解决方法:编辑(或新建) webapps/jenkins.xml 文件,添加如下配置。

1
2
3
4
5
6
7
8
9
10
11
12
13
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/jenkins</Set>
<Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/jenkins.war</Set>
<Get name="securityHandler">
<Set name="loginService">
<New class="org.eclipse.jetty.security.HashLoginService">
<Set name="name">Jenkins Realm</Set>
<Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
</New>
</Set>
</Get>
 
</Configure>

另外,Jetty 自带的示例:webapps.demo/test.xml 中也有security realm相关的配置。 
解决了这两个问题后,Jenkins示例URL:http://192.168.52.11:8080/jenkins/ 就可以正常访问了。

参考资料:

http://www.eclipse.org/jetty/documentation/current/what-jetty-version.html

http://stackoverflow.com/questions/9111759/http-error-503-accessing-jenkins-reason-service-unavailable

https://wiki.jenkins-ci.org/display/JENKINS/Jetty

最新文章

  1. Hibernate 非常见异常集合
  2. Python学习笔记(2):数据库访问
  3. How to use python remove the &#39;^M&#39; when copy words from Windows to Linux
  4. wpa_supplicant软件架构分析
  5. UEditor上传图片等附件都出现红叉
  6. demo_04绘制三角形
  7. HDU 1247
  8. 手机时间选择插件 Jquery
  9. 005 列表以及append,extend方法
  10. 几种经典排序算法的JS实现
  11. 用apache配置多个tomcat webapp
  12. js随机模块颜色
  13. (高级篇 Netty多协议开发和应用)第十章-Http协议开发应用(基于Netty的HttpServer和HttpClient的简单实现)
  14. Linux System Programming --Chapter Eight
  15. 内存压测工具Memtester
  16. iOS 类方法 、野指针与空指针
  17. spark join
  18. 再学Java 之 Integer 包装类缓存
  19. iOS:UIPickerView选择器的使用
  20. 从github上下载项目到eclipse

热门文章

  1. ZOJ 1608 Two Circles and a Rectangle
  2. (20)打鸡儿教你Vue.js
  3. C#题(子文章)(持续更新)
  4. 如何在wcf中用net tcp协议进行通讯
  5. 元素在当前窗口可视的区域---Element.scrollIntoView()
  6. rsync详解之exclude排除文件【转】
  7. Mysql中 查询慢的 Sql语句的记录查找
  8. 借助中间件优化代码 将请求RequestId在服务端接收到请求在处理业务逻辑之前生成
  9. GIS空间分析案例教程——带背景和周围要素的逐要素导出地理
  10. git 删除远程和本地分支