2012年4月25日水曜日

CentOSにJenkinsを入れる その1

この投稿へのリンク
さくらのVPSを借りたのでJenkinsやらなんやらを入れて遊ぼうと思ったので環境構築をしててハマったのでまとめる

環境

以下の環境で作業

  • CentOS 6.2 x86_64
  • メモリ 1G
  • ディスク 100G

Jenkinsのインストール

yumで突っ込めるようにさくっとやる
公式を参考に

$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
$ sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
そんで、
$ sudo yum -y install jenkins

ポートを開放する必要があるからiptablesの設定を編集
$ sudo vi /etc/sysconfig/iptables


設定内容はこんな感じ
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [82:13644]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT 
-A FORWARD -j RH-Firewall-1-INPUT 
-A RH-Firewall-1-INPUT -i lo -j ACCEPT 
-A RH-Firewall-1-INPUT -p icmp -m icmp --icmp-type any -j ACCEPT 
-A RH-Firewall-1-INPUT -p esp -j ACCEPT 
-A RH-Firewall-1-INPUT -p ah -j ACCEPT 
-A RH-Firewall-1-INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT 
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT 
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 8009 -j ACCEPT 
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT 
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 20022 -j ACCEPT 
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 20021 -j ACCEPT 
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 20025 -j ACCEPT 
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited 
COMMIT

で、jenkinsの起動
$ sudo service jenkins start
Starting Jenkins                                           [  OK  ]


はい。この[  OK  ]に騙されていました。
プロセスを確認してみるとjenkinsが動いとりません。
$ sudo ps -x


なんでかなぁと思い、みやびーに聞いた所、直接jenkinsを起動してみろとのこと。
$ cd /usr/lib/jenkins
$ java -jar jenkins.war
Running from: jenkins.war
webroot: $user.home/.jenkins
2012/04/25 23:36:19 winstone.Logger logInternal
INFO: Beginning extraction from war file
2012/04/25 23:36:22 hudson.WebAppMain contextInitialized
SEVERE: Failed to initialize Jenkins
java.lang.ExceptionInInitializerError
   at java.lang.Class.initializeClass(libgcj.so.10)
   at hudson.WebAppMain.installLogger(WebAppMain.java:256)
   at hudson.WebAppMain.contextInitialized(WebAppMain.java:107)
   at winstone.WebAppConfiguration.(WebAppConfiguration.java:875)
   at winstone.HostConfiguration.initWebApp(HostConfiguration.java:129)
   at winstone.HostConfiguration.(HostConfiguration.java:71)
   at winstone.HostGroup.initHost(HostGroup.java:87)
   at winstone.HostGroup.(HostGroup.java:47)
   at winstone.Launcher.(Launcher.java:177)
   at winstone.Launcher.main(Launcher.java:384)
   at java.lang.reflect.Method.invoke(libgcj.so.10)
   at Main._main(Main.java:273)
   at Main.main(Main.java:98)
Caused by: java.lang.NullPointerException
   at com.thoughtworks.xstream.core.JVM.isOpenJDK(JVM.java:72)
   at com.thoughtworks.xstream.core.JVM.canUseSun14ReflectionProvider(JVM.java:198)
   at com.thoughtworks.xstream.core.JVM.bestReflectionProvider(JVM.java:175)
   at com.thoughtworks.xstream.XStream.(XStream.java:431)
   at com.thoughtworks.xstream.XStream.(XStream.java:385)
   at com.thoughtworks.xstream.XStream.(XStream.java:323)
   at hudson.util.XStream2.(XStream2.java:75)
   at jenkins.model.Jenkins.(Jenkins.java:3677)
   at java.lang.Class.initializeClass(libgcj.so.10)
   ...12 more
2012/04/25 23:36:22 winstone.Logger logInternal
SEVERE: Error during context startup for webapp webapp
java.lang.ExceptionInInitializerError
   at java.lang.Class.initializeClass(libgcj.so.10)
   at hudson.WebAppMain.installLogger(WebAppMain.java:256)
   at hudson.WebAppMain.contextInitialized(WebAppMain.java:107)
   at winstone.WebAppConfiguration.(WebAppConfiguration.java:875)
   at winstone.HostConfiguration.initWebApp(HostConfiguration.java:129)
   at winstone.HostConfiguration.(HostConfiguration.java:71)
   at winstone.HostGroup.initHost(HostGroup.java:87)
   at winstone.HostGroup.(HostGroup.java:47)
   at winstone.Launcher.(Launcher.java:177)
   at winstone.Launcher.main(Launcher.java:384)
   at java.lang.reflect.Method.invoke(libgcj.so.10)
   at Main._main(Main.java:273)
   at Main.main(Main.java:98)
Caused by: java.lang.NullPointerException
   at com.thoughtworks.xstream.core.JVM.isOpenJDK(JVM.java:72)
   at com.thoughtworks.xstream.core.JVM.canUseSun14ReflectionProvider(JVM.java:198)
   at com.thoughtworks.xstream.core.JVM.bestReflectionProvider(JVM.java:175)
   at com.thoughtworks.xstream.XStream.(XStream.java:431)
   at com.thoughtworks.xstream.XStream.(XStream.java:385)
   at com.thoughtworks.xstream.XStream.(XStream.java:323)
   at hudson.util.XStream2.(XStream2.java:75)
   at jenkins.model.Jenkins.(Jenkins.java:3677)
   at java.lang.Class.initializeClass(libgcj.so.10)
   ...12 more
2012/04/25 23:36:22 winstone.Logger logInternal
INFO: HTTP Listener started: port=8080
2012/04/25 23:36:22 winstone.Logger logInternal
INFO: AJP13 Listener started: port=8009
2012/04/25 23:36:22 winstone.Logger logInternal
SEVERE: Error during servlet context shutdown
java.lang.NoClassDefFoundError: jenkins.model.Jenkins
   at java.lang.Class.initializeClass(libgcj.so.10)
   at hudson.WebAppMain.contextDestroyed(WebAppMain.java:339)
   at winstone.WebAppConfiguration.destroy(WebAppConfiguration.java:1149)
   at winstone.HostConfiguration.destroyWebApp(HostConfiguration.java:148)
   at winstone.HostConfiguration.destroy(HostConfiguration.java:156)
   at winstone.HostGroup.destroy(HostGroup.java:77)
   at winstone.Launcher.shutdown(Launcher.java:337)
   at winstone.Launcher.(Launcher.java:199)
   at winstone.Launcher.main(Launcher.java:384)
   at java.lang.reflect.Method.invoke(libgcj.so.10)
   at Main._main(Main.java:273)
   at Main.main(Main.java:98)
2012/04/25 23:36:22 winstone.Logger logInternal
INFO: Winstone shutdown successfully
2012/04/25 23:36:22 winstone.Logger logInternal
SEVERE: Container startup failed
java.io.IOException: Failed to start a listener: winstone.ssl.HttpsListener
   at winstone.Launcher.spawnListener(Launcher.java:229)
   at winstone.Launcher.(Launcher.java:185)
   at winstone.Launcher.main(Launcher.java:384)
   at java.lang.reflect.Method.invoke(libgcj.so.10)
   at Main._main(Main.java:273)
   at Main.main(Main.java:98)
Caused by: java.lang.NoClassDefFoundError: winstone.ssl.HttpsListener
   at java.lang.Class.initializeClass(libgcj.so.10)
   at java.lang.Class.forName(libgcj.so.10)
   at winstone.Launcher.spawnListener(Launcher.java:213)
   ...5 more
Caused by: java.lang.ClassNotFoundException: sun.security.util.DerValue not found in java.net.URLClassLoader{urls=[file:/tmp/winstoneplgbf6jar], parent=gnu.gcj.runtime.SystemClassLoader{urls=[file:jenkins.war], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}}
   at java.net.URLClassLoader.findClass(libgcj.so.10)
   at java.lang.ClassLoader.loadClass(libgcj.so.10)
   at java.lang.ClassLoader.loadClass(libgcj.so.10)
   at java.lang.Class.initializeClass(libgcj.so.10)
   ...7 more


わっさーとエラーが出てきました。どうやらjenkins自体のインストールがうまくいってない?
ここから問題を解決していきたいと思います。

#追記
コメントで指摘をもらったようにOpenJDKをインストールすると無事起動できるようになった。

#以下アフィリエイト用の広告です