在Jenkins的Maven构建期间不支持的类版本

时间:2014-09-03 23:47:42

标签: java maven jenkins java-7 jdk6

我已经在这里看到了其中一些问题,但没有一个解决方案/提示似乎指向了我正确的方向。所以我在" / opt / java / 6"," / opt / java / 7"和" / opt /的位置安装了3个JDK的java / 8&#34 ;.所有这些都在全局Jenkins配置中设置。 Jenkins本身使用Java 8运行,这是我通过备选方案手动设置的系统默认JRE(我使用CentOS 7)。我有一堆旧的项目,使用maven和maven编译器插件构建,设置为source = 1.6 target = 1.6。每次我尝试使用Java 6 JDK执行构建时,我都会得到

  

Started by user Antony Prince
  ln builds/lastSuccessfulBuild /var/lib/jenkins/jobs/BitCalculator/lastSuccessful failed
  java.nio.file.DirectoryNotEmptyException: /var/lib/jenkins/jobs/BitCalculator/lastSuccessful
  at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:242)
  at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108)
  at java.nio.file.Files.deleteIfExists(Files.java:1165)
  at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:483)
  at hudson.Util.createSymlinkJava7(Util.java:1194)
  at hudson.Util.createSymlink(Util.java:1112)
  at hudson.model.Run.createSymlink(Run.java:1851)
  at hudson.model.Run.updateSymlinks(Run.java:1832)
  at hudson.model.Run.execute(Run.java:1743)
  at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)
  at hudson.model.ResourceController.execute(ResourceController.java:89)
  at hudson.model.Executor.run(Executor.java:240)
  ln builds/lastStableBuild /var/lib/jenkins/jobs/BitCalculator/lastStable failed
  java.nio.file.DirectoryNotEmptyException: /var/lib/jenkins/jobs/BitCalculator/lastStable
  at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:242)
  at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108)
  at java.nio.file.Files.deleteIfExists(Files.java:1165)
  at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:483)
  at hudson.Util.createSymlinkJava7(Util.java:1194)
  at hudson.Util.createSymlink(Util.java:1112)
  at hudson.model.Run.createSymlink(Run.java:1851)
  at hudson.model.Run.updateSymlinks(Run.java:1833)
  at hudson.model.Run.execute(Run.java:1743)
  at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)
  at hudson.model.ResourceController.execute(ResourceController.java:89)
  at hudson.model.Executor.run(Executor.java:240)
  Building in workspace /var/lib/jenkins/workspace/BitCalculator
  > git rev-parse --is-inside-work-tree # timeout=10
  Fetching changes from the remote Git repository
  > git config remote.origin.url /home/git/repositories/java/BitCalculator.git # timeout=10
  Fetching upstream changes from /home/git/repositories/java/BitCalculator.git
  > git --version # timeout=10
  > git fetch --tags --progress /home/git/repositories/java/BitCalculator.git +refs/heads/*:refs/remotes/origin/*
  > git rev-parse origin/master^{commit} # timeout=10
  Checking out Revision 4f119f7783cc4ff00e5bf9bb27850ae7698d4fe8 (origin/master)
  > git config core.sparsecheckout # timeout=10
  > git checkout -f 4f119f7783cc4ff00e5bf9bb27850ae7698d4fe8
  > git rev-list 4f119f7783cc4ff00e5bf9bb27850ae7698d4fe8 # timeout=10
  Parsing POMs
  [BitCalculator] $ /opt/java/6/bin/java -Djava.awt.headless=true -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.5.jar:/usr/share/maven/boot/plexus-classworlds.jar org.jvnet.hudson.maven3.agent.Maven3Main /usr/share/maven /var/lib/jenkins/war/WEB-INF/lib/remoting-2.44.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.5.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.5.jar 56445
  <===[JENKINS REMOTING CAPACITY]===>channel started
  Executing Maven: -B -f /var/lib/jenkins/workspace/BitCalculator/pom.xml -P sign clean deploy
  java.lang.reflect.InvocationTargetException
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:331)
  at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
  at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:178)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at hudson.maven.Maven3Builder.call(Maven3Builder.java:134)
  at hudson.maven.Maven3Builder.call(Maven3Builder.java:69)
  at hudson.remoting.UserRequest.perform(UserRequest.java:118)
  at hudson.remoting.UserRequest.perform(UserRequest.java:48)
  at hudson.remoting.Request$2.run(Request.java:328)
  at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
  at java.util.concurrent.FutureTask.run(FutureTask.java:138)
  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
  at java.lang.Thread.run(Thread.java:662)
  Caused by: java.lang.UnsupportedClassVersionError: javax/inject/Provider : Unsupported major.minor version 51.0
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
  at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
  at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:386)
  at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
  at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
  at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
  at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:86)
  ... 22 more
  channel stopped
  [BitCalculator] $ /bin/sh -xe /tmp/hudson6524656470722686910.sh
  + rm 'target/*no_deps*'
  rm: cannot remove 'target/*no_deps*': No such file or directory
  Build step 'Execute shell' marked build as failure
  ERROR: Failed to parse POMs
  hudson.util.IOException2: java.lang.reflect.InvocationTargetException
  at hudson.maven.Maven3Builder.call(Maven3Builder.java:178)
  at hudson.maven.Maven3Builder.call(Maven3Builder.java:69)
  at hudson.remoting.UserRequest.perform(UserRequest.java:118)
  at hudson.remoting.UserRequest.perform(UserRequest.java:48)
  at hudson.remoting.Request$2.run(Request.java:328)
  at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
  at java.util.concurrent.FutureTask.run(FutureTask.java:138)
  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
  at java.lang.Thread.run(Thread.java:662)
  Caused by: java.lang.reflect.InvocationTargetException
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at hudson.maven.Maven3Builder.call(Maven3Builder.java:134)
  ... 10 more
  Caused by: java.lang.Exception: java.lang.reflect.InvocationTargetException
  at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:181)
  ... 15 more
  Caused by: java.lang.reflect.InvocationTargetException
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:331)
  at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
  at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:178)
  ... 15 more
  Caused by: java.lang.UnsupportedClassVersionError: javax/inject/Provider : Unsupported major.minor version 51.0
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
  at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
  at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:386)
  at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
  at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
  at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
  at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:86)
  ... 22 more
  Archiving artifacts
  Sending e-mails to: antony@blazrsoft.com
  Finished: FAILURE

这表明Java 7在某处干扰,但我不知道在哪里。 代码是1.6兼容的,大多数项目没有依赖关系,所以我不确定为什么会这样。如果我在Jenkins之外执行maven,这些项目在JDK 6中构建得很好,所以它引导我认为Jenkins在某个地方存在错误的配置,但是我不确定哪里因为它应该是应该的是。 JDK的路径在全局配置中正确设置,项目本身设置为使用指定的JDK。如果它是一个重复的问题或愚蠢的事情,我道歉,但我一直试图解决这个问题几天没有结果。每个人都说要检查路径并确保没有使用后来的JDK构建的依赖工件,我确信这不是问题。

$ mvn -version
Apache Maven 3.0.5 (Red Hat 3.0.5-16)
Maven home: /usr/share/maven
Java version: 1.8.0_20, vendor: Oracle Corporation
Java home: /opt/java/8/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "2.6.32-openvz-042stab090.5-amd64", arch: "amd64", family: "unix"

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.6</source>
<target>1.6</target>
<compilerVersion>1.6</compilerVersion>
</configuration>
</plugin>

1 个答案:

答案 0 :(得分:0)

你有一个旧的java版本。例如,在我的情况下,我正在编译一个旧产品,所以我必须保持java弃用版本。 所以解决方案是下载最新的jdk并在slave中配置JAVA_HOME。 高级/ JavaPath = / root / jdk1.7.0_79 / bin / java(这是我选择的版本)一节中的http://lmarccdk12.ptx.fr.sopra:14000/computer/ / configure

您将在从属启动日志中看到以下消息: [SSH]启动奴隶进程:cd“/ root”&amp;&amp; /root/jdk1.7.0_79/bin/java -jar slave.jar