Skip to content

Instantly share code, notes, and snippets.

@mgarciap
Last active November 21, 2017 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgarciap/baf41302bd9c1b79ed43 to your computer and use it in GitHub Desktop.
Save mgarciap/baf41302bd9c1b79ed43 to your computer and use it in GitHub Desktop.
Deploying Jenkins to Cloud Foundry
2014-10-08T23:26:24.61-0300 [API] OUT Created app with guid de613b7d-5d86-4c04-9d4f-d9af778d8148
2014-10-08T23:26:24.76-0300 [API] OUT Updated app with guid de613b7d-5d86-4c04-9d4f-d9af778d8148 ({"route"=>"63214764-8a1e-4eb0-9856-e906ba666203"})
2014-10-08T23:26:45.21-0300 [DEA] OUT Got staging request for app with id de613b7d-5d86-4c04-9d4f-d9af778d8148
2014-10-08T23:26:46.85-0300 [API] OUT Updated app with guid de613b7d-5d86-4c04-9d4f-d9af778d8148 ({"state"=>"STARTED"})
2014-10-08T23:26:47.51-0300 [STG] OUT -----> Downloaded app package (60M)
2014-10-08T23:26:50.83-0300 [STG] OUT -----> Java Buildpack Version: v2.4 | https://github.com/cloudfoundry/java-buildpack.git#7cdcf1a
2014-10-08T23:30:54.46-0300 [STG] OUT -----> Downloading Open Jdk JRE 1.7.0_65 from https://download.run.pivotal.io/openjdk/lucid/x86_64/openjdk-1.7.0_65.tar.gz (4m 3s)
2014-10-08T23:30:55.24-0300 [STG] OUT Expanding Open Jdk JRE to .java-buildpack/open_jdk_jre (0.7s)
2014-10-08T23:31:00.50-0300 [STG] OUT -----> Downloading Spring Auto Reconfiguration 1.5.0_RELEASE from https://download.run.pivotal.io/auto-reconfiguration/auto-reconfiguration-1.5.0_RELEASE.jar (5.
2s)
2014-10-08T23:31:00.50-0300 [STG] OUT Modifying /WEB-INF/web.xml for Auto Reconfiguration
2014-10-08T23:31:09.55-0300 [STG] OUT -----> Uploading droplet (91M)
2014-10-08T23:31:15.16-0300 [DEA] OUT Starting app instance (index 0) with guid de613b7d-5d86-4c04-9d4f-d9af778d8148
2014-10-08T23:31:18.20-0300 [App/0] ERR ZipFile.name trick did not work, using fallback: java.lang.ClassCastException: sun.net.www.protocol.file.FileURLConnection cannot be cast to java.net.JarURLConne
ction
2014-10-08T23:31:18.28-0300 [App/0] OUT Running from: /home/vcap/tmp/jenkins4877337799591593127.jar
2014-10-08T23:31:18.29-0300 [App/0] OUT webroot: $user.home/.jenkins
2014-10-08T23:31:18.43-0300 [App/0] ERR Oct 09, 2014 2:31:18 AM winstone.Logger logInternal
2014-10-08T23:31:18.43-0300 [App/0] ERR INFO: Beginning extraction from war file
2014-10-08T23:31:18.43-0300 [App/0] ERR Oct 09, 2014 2:31:18 AM winstone.Logger logInternal
2014-10-08T23:31:18.43-0300 [App/0] ERR INFO: Winstone shutdown successfully
2014-10-08T23:31:18.43-0300 [App/0] ERR Oct 09, 2014 2:31:18 AM winstone.Logger logInternal
2014-10-08T23:31:18.43-0300 [App/0] ERR SEVERE: Container startup failed
2014-10-08T23:31:18.43-0300 [App/0] ERR java.util.zip.ZipException: error in opening zip file
2014-10-08T23:31:18.43-0300 [App/0] ERR at java.util.zip.ZipFile.open(Native Method)
2014-10-08T23:31:18.43-0300 [App/0] ERR at java.util.zip.ZipFile.<init>(ZipFile.java:215)
2014-10-08T23:31:18.43-0300 [App/0] ERR at java.util.zip.ZipFile.<init>(ZipFile.java:145)
2014-10-08T23:31:18.43-0300 [App/0] ERR at java.util.jar.JarFile.<init>(JarFile.java:154)
2014-10-08T23:31:18.43-0300 [App/0] ERR at java.util.jar.JarFile.<init>(JarFile.java:118)
2014-10-08T23:31:18.43-0300 [App/0] ERR at winstone.HostConfiguration.getWebRoot(HostConfiguration.java:260)
2014-10-08T23:31:18.43-0300 [App/0] ERR at winstone.HostConfiguration.<init>(HostConfiguration.java:81)
2014-10-08T23:31:18.43-0300 [App/0] ERR at winstone.HostGroup.initHost(HostGroup.java:66)
2014-10-08T23:31:18.43-0300 [App/0] ERR at winstone.HostGroup.<init>(HostGroup.java:45)
2014-10-08T23:31:18.43-0300 [App/0] ERR at winstone.Launcher.<init>(Launcher.java:143)
2014-10-08T23:31:18.43-0300 [App/0] ERR at winstone.Launcher.main(Launcher.java:354)
2014-10-08T23:31:18.43-0300 [App/0] ERR at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2014-10-08T23:31:18.43-0300 [App/0] ERR at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
2014-10-08T23:31:18.43-0300 [App/0] ERR at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2014-10-08T23:31:18.43-0300 [App/0] ERR at java.lang.reflect.Method.invoke(Method.java:606)
2014-10-08T23:31:18.43-0300 [App/0] ERR at Main._main(Main.java:293)
2014-10-08T23:31:18.43-0300 [App/0] ERR at Main.main(Main.java:98)
2014-10-08T23:31:18.48-0300 [DEA] ERR Instance (index 0) failed to start accepting connections
2014-10-08T23:31:18.48-0300 [API] OUT App instance exited with guid de613b7d-5d86-4c04-9d4f-d9af778d8148 payload: {"cc_partition"=>"default", "droplet"=>"de613b7d-5d86-4c04-9d4f-d9af778d8148", "versi
on"=>"cda08a67-022c-4024-a5d9-a940b2930800", "instance"=>"f3136581f72e4b8fb6341e76509f7d18", "index"=>0, "reason"=>"CRASHED", "exit_status"=>0, "exit_description"=>"app instance exited", "crash_timestamp
"=>1412821878}
HOW TO DEPLOY JENKINS TO CF
— Requirements —
a) java
b) maven
- NOTES —
This has been done in Bosh-Lite. CF-RELEASE v177
The workaround is found in:
http://stackoverflow.com/questions/325202/java-util-zip-zipexception-error-in-opening-zip-file
Take a look at this comment:
I've had this problem on Mac when Windows and Linux worked just fine. Using JarInputStream fixed the problem for me.
1) Retrieve source code
$ git clone https://github.com/jenkinsci/jenkins.git
(takes time, big repo)
2) Build
$ cd jenkins
$ mvn clean install -pl war -am -DskipTests
(It may take a looong time if you’ve never run it before. It will download every single dependency and compile)
Resulting package (Java Web ARchive) is left in: war/target/jenkins.war
3) Deploy
If you deploy the generated war, you’ll end up with the following error: java.util.zip.ZipException: error in opening zip file
https://gist.github.com/mgarciap/baf41302bd9c1b79ed43
This is due recursive dependencies (jars inside jars. Jars are zip files)
FIX: extract file and zip it again
(This has been done in Mac)
Create a clean directory and unzip WAR file in there
$ mkdir jenkins-fix && cd jenkins-fix
$ unzip ../jenkins.war
Zip it again (yes, it is crazy but it is what it is)
$ zip -r jenkins-fixed.war .
Deploy the good one:
$ cf push -p jenkins-fixed.war jenkins-fixed
4) Test
Open browser: jenkins-fixed..10.244.0.34.xip.io
Notes about this way to deploy Jenkins:
- It will use local storage, violating the 12factor rule. Local storage is not sharable.
This will have a restriction: run it in only 1 instance.
@ManojKuppaiahSudhakara
Copy link

I tried with same approach what you have mentioned. am facing same error

ERR ZipFile.name trick did not work, using fallback: java.lang.ClassCastException: sun.net.www.protocol.file.FileURLConnection incompatible with java.net.JarURLConnection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment