Skip to content

Instantly share code, notes, and snippets.

@m0un10
Last active July 4, 2019 22:20
Show Gist options
  • Save m0un10/e36a2b4b823672e68dbf7f6fdf288918 to your computer and use it in GitHub Desktop.
Save m0un10/e36a2b4b823672e68dbf7f6fdf288918 to your computer and use it in GitHub Desktop.
Upgrading Jenkins 1.x to 2.x

This is a brute force approach that helped me to upgrade from Jenkins 1.x to 2.x without much pain.

  1. Upgrade Jenkins from the web-console. This is an option under "Manage Jenkins"
  2. If it fails to boot up, check the Jenkins log. In my case, this was at /opt/jenkins/log/jenkins.log
  3. There may be multiple iterations required to fix missing dependencies or invalid/old configurations from Jenkins 1.x. I found it useful to start Jenkins (e.g. service jenkins start) then check the log and make adjustments to fix any startup errors.
  4. Once startup is successful, there will be a "Upgrade Now" banner in the Jenkins web-console. You can click on this and follow the prompts to choose valuable Jenkins 2 plugins such as the "Pipeline Plugin". This plugin allows support of the Jenkinsfile to automate end-to-end Continuous Delivery Pipelines in Jenkins.

The following are resolutions for common startup issues after upgrading Jenkins 1.x to 2.x

  • Remove AJP
  • Upgrade Java 7 to 8

Remove AJP

If you still have AJP enabled your startup will fail with this:

SEVERE: Container startup failed
java.io.IOException: Failed to start a listener: winstone.Ajp13ConnectorFactory
	at winstone.Launcher.spawnListener(Launcher.java:207)
	at winstone.Launcher.<init>(Launcher.java:148)
	at winstone.Launcher.main(Launcher.java:352)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at Main._main(Main.java:264)
	at Main.main(Main.java:112)
Caused by: java.lang.UnsupportedOperationException: AJP support is removed in Winstone 3.0 due to Jetty 9 not supporting AJP. For reverse proxying, please use HTTP instead of AJP.
	at winstone.Ajp13ConnectorFactory.start(Ajp13ConnectorFactory.java:32)
	at winstone.Launcher.spawnListener(Launcher.java:205)
	... 8 more

You can fix this by updating Jenkins configuration to disable AJP. If you don't know where the file is best thing is to check the start up script. In my case, I checked /etc/init.d/jenkins and found the line JENKINS_CONFIG=/opt/jenkins/config/jenkins so I opened this file and changed JENKINS_AJP_PORT="8009" to JENKINS_AJP_PORT="-1"

Upgrade Java 7 to 8

If you still have Java 7, your startup will fail with this:

java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:85)
	at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:72)
	at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:408)
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1340)
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:505)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
	at org.eclipse.jetty.server.Server.start(Server.java:387)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
	at org.eclipse.jetty.server.Server.doStart(Server.java:354)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
	at winstone.Launcher.<init>(Launcher.java:152)
	at winstone.Launcher.main(Launcher.java:352)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at Main._main(Main.java:264)
	at Main.main(Main.java:112)
Caused by: java.lang.UnsupportedClassVersionError: jenkins/util/SystemProperties : Unsupported major.minor version 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at org.eclipse.jetty.webapp.WebAppClassLoader.findClass(WebAppClassLoader.java:510)
	at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:441)
	at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:403)
	at org.eclipse.jetty.server.handler.ContextHandler.loadClass(ContextHandler.java:1583)
	at org.eclipse.jetty.webapp.StandardDescriptorProcessor.visitListener(StandardDescriptorProcessor.java:1956)
	... 25 more

You can fix this by upgrading to Java 8. The steps I took to do this on RedHat-like machine are:

  • Install via Yum yum install java-1.8.0-openjdk.x86_64
  • Verify the Java version with java -version which should yield an output like this:
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment