在Jetty中部署Jenkins遇到的问题

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 [email protected]70188b41: java.lang.IllegalStateException: No LoginService for [email protected]790bb6f4 in [email protected]70188b41
java.lang.IllegalStateException: No LoginService for [email protected]790bb6f4 in [email protected]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 [email protected]5b5e91e5: java.lang.IllegalStateException: No LoginService for [email protected]790bb6f4 in [email protected]70188b41
java.lang.IllegalStateException: No LoginService for [email protected]790bb6f4 in [email protected]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 [email protected]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 [email protected]790bb6f4 in [email protected]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

时间: 2024-08-04 01:36:57

在Jetty中部署Jenkins遇到的问题的相关文章

在嵌入式Jetty(Embedded Jetty)中部署FastCGI Servlet载入PHP程序

这段时间由于服务器架构,需要研究在Java基础上的Jetty中部署PHP程序(Wordpress,Discuz) 在网上查了很多资料,都是用httpd或者nginx当前段Web Server,Jetty在后台服务器的.介于我之前用的嵌入式Jetty(embedded jetty),所以并不适合这种解决方案. 后来又搜索了一下,发现Jetty原来本身就有这个支持: http://www.eclipse.org/jetty/documentation/9.2.7.v20150116/configur

K8S集群中部署jenkins

本文介绍在k8s环境中进行jenkins server的部署和配置.Jenkins是一个开源的.功能强大的持续集成和持续构建工具,采用master和salve架构,我们通过将jenkins集成环境部署在k8s集群中,可以实现jenkins slave按需创建.动态的伸缩.同时也提供了在k8s环境中应用的持续部署解决方案. 一.准备docker镜像文件 1.编译jenkins server docker镜像,默认的jenkis镜像已包含jdk,版本为1.8.0_171 # cat dockerfi

Ubuntu中安装jenkins+docker,实现项目部署

本人对于linux系统是个小白,恰逢公司新框架需要docker+jenkins部署项目,所以通过同事口述+一顿乱查,终于实现在虚拟机上搭建的ubuntu系统中 实现jenkins +docker 自动部署拉取项目. 赶紧做个记录! 准备条件: 1.虚拟机内安装ubuntu随后再做记录,虽说同事已经演示过,但是自己还是得记录下. 2.jenkins 需要环境:由于本人直接将jenkins安装于宿主机中(还可以将jenkins安装于docker中---这个随后再研究,一步一步来),所以需要JDK+T

docker部署Jenkins,以及在Jenkins中使用宿主机的docker/docker-compose命令

使用最新的官方镜像jenkins/jenkins 第一次使用的docker部署jenkins的时候,出现了两个问题: 1.因为用户权限问题挂载/home/jenkins/data到/var/jenkins_home挂载不了.后面通过修改data目录的所属用户可以解决,即在容器下查询用户id(1000),然后把data改成同样的用户id 2.即便挂载docker命名和docker.sock,也修改了相应的权限,仍存在libltdl7没有权限读取.当然好像也不影响使用,只是在容器里面执行docker

jetty9配置指南及jetty9部署jenkins

jetty下载地址: https://www.eclipse.org/jetty/download.html jetty的安装: 下载.tgz的包解压缩的指定目录后即可 例如:将jetty-distribution-9.4.6.v20170531.tar.gz包解压缩到/usr/local/jetty目录. 我们默认把jetty的根目录当成 $JETTY_HOME jetty目录结构: [[email protected] jetty01]# ll total 712 drwxr-xr-x  2

jetty热部署,持久化session,jetty-maven插件配置

持久化session 背景 使用maven管理项目,使用jetty插件启动项目,虽然jetty是热部署的,但是没有配置的jetty并不算真正的热部署.因为在没有配置前每次热部署都会把session丢了.导致测试期间的数据丢失,重来一遍很麻烦. 本人使用的是jetty-maven-plugin,关于这个插件的一些基本配置就不说了,网上很多. 配置代码pom <plugin> <groupId>org.mortbay.jetty</groupId> <artifact

在Tomcat 中部署Solr4.x

1.安装Tomcat (1)下载并解压至/opt/tomcat中 [[email protected] solr]# cd /opt [[email protected] opt]# tar -zxvf apache-tomcat-7.0.54.tar.gz [[email protected] opt]# mv apache-tomcat-7.0.54 tomcat 将目录重命名为tomcat [[email protected] opt]# ls apache-tomcat-7.0.54.t

Jetty:部署到Jetty

Web应用的框架 标准Jetty公布版本号能部署标准servlet Spec Web应用和Jetty内部ContextHandler部署描写叙述符,或者两者的一个混合. Web应用是可部署的动态(servlets.filters.jsps.等等)和静态内容.支持库.和绑定到特定上下文路径的描写性的元数据的集合. 格式和布局终于都是通过Servlet Spec定义.你能够查阅官方Servlet Spec文档获取关于Web应用布局和结构的很多其它细节,这里将给出一个主要的轮廓. Web应用能被捆绑到

linux下部署jenkins

今天做作业连了一天的mysql. 最后我痛定思痛,决定从0开始学习jsp,省的又面临不会的局面. 忙活了一晚上,终于把数据库连接上了,不过,好伤心啊,我连个数据库都这么墨迹... <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@page import="data.database"%> <%@page