简体   繁体   English

不支持 Class 版本在 Maven build in Jenkins

[英]Unsupported Class Version during Maven build in Jenkins

I've seen a few of these questions on here, but none of the solutions/tips seem to be pointing me in the right direction.我在这里看到了其中一些问题,但似乎没有一个解决方案/提示能为我指明正确的方向。 So I have 3 JDK's installed in the locations of "/opt/java/6", "/opt/java/7", and "/opt/java/8".所以我在“/opt/java/6”、“/opt/java/7”和“/opt/java/8”的位置安装了 3 个 JDK。 All of these are set in the global Jenkins configuration.所有这些都在全局 Jenkins 配置中设置。 Jenkins itself is run using Java 8 which is the system default JRE that I set manually through alternatives (I'm using CentOS 7). Jenkins 本身使用 Java 8 运行,这是我通过替代方法手动设置的系统默认 JRE(我使用的是 CentOS 7)。 I had a bunch of old projects that are built using maven and the maven compiler plugin which is set to source=1.6 target=1.6.我有一堆旧项目是使用 maven 和 maven 编译器插件构建的,该插件设置为 source=1.6 target=1.6。 Every time I try to execute a build with the Java 6 JDK I get每次我尝试使用 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.j.net.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.j.net.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.j.net.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.j.net.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.j.net.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.j.net.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:86)
... 22 more
Archiving artifacts
Sending e-mails to: antony@blazrsoft.com
Finished: FAILURE

This indicates that there's Java 7 interfering somewhere, but I'm not sure where.这表明有 Java 7 干扰某处,但我不确定在哪里。 The code is 1.6 compliant and most of the projects have no dependencies, so I'm not sure why this is happening.该代码符合 1.6 标准,并且大多数项目都没有依赖项,所以我不确定为什么会这样。 If I execute maven outside of Jenkins, the projects build just fine with JDK 6, so its leading me to think there's a misconfiguration in Jenkins somewhere, but I'm not sure where since everything seems to be as it should be.如果我在 Jenkins 之外执行 maven,则项目使用 JDK 6 构建得很好,所以它让我认为 Jenkins 某处存在错误配置,但我不确定在哪里,因为一切似乎都应该如此。 The paths to the JDKs are set properly in the global config and the projects themselves are set to use the specified JDK's. JDK 的路径在全局配置中正确设置,项目本身设置为使用指定的 JDK。 I apologize if its a duplicate question or something silly, but I've been trying to figure this out for days with no results.如果这是一个重复的问题或一些愚蠢的问题,我深表歉意,但我已经尝试了好几天都没有结果。 Everyone just says to check the paths and make sure there are no dependent artifacts built with a later JDK and I'm sure that this is not the problem.每个人都说要检查路径并确保没有使用更高版本的 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>

You have an old java version. 您有一个旧的Java版本。 For example in my case I´m compiling an old product so I have to keep the java deprecated version. 例如,在我的情况下,我正在编译一个旧产品,因此必须保留不推荐使用的Java版本。 So the solution was to download a newest jdk and configure the JAVA_HOME in the slave. 因此,解决方案是下载最新的jdk并在从属服务器中配置JAVA_HOME。 http://lmarccdk12.ptx.fr.sopra:14000/computer/ /configure in the section Advanced/JavaPath=/root/jdk1.7.0_79/bin/java (that´s the version I chose) http://lmarccdk12.ptx.fr.sopra:14000 / computer / / configure(位于Advanced / JavaPath = / root / jdk1.7.0_79 / bin / java部分)中(这是我选择的版本)

You will see the following message in the slave launch log: [SSH] Starting slave process: cd "/root" && /root/jdk1.7.0_79/bin/java -jar slave.jar 您将在从属启动日志中看到以下消息:[SSH]正在启动从属进程:cd“ / root” && / /root/jdk1.7.0_79/bin/java -jar slave.jar

Your Jenkins job is of type "Maven project", and this job type has a limitation in that it cannot run a Maven build with a JDK version that is older than the Java version under which Jenkins is run.您的 Jenkins 作业类型为“Maven 项目”,此作业类型有一个限制,即它不能运行 Maven 构建,其 JDK 版本比运行 Jenkins 的 Java 版本旧。

Beginning with Jenkins 2.357 (released on June 28, 2022) and the forthcoming 2.361.1 LTS release, Jenkins requires Java 11 or newer.从 Jenkins 2.357(2022 年 6 月 28 日发布)和即将发布的 2.361.1 LTS 版本开始,Jenkins 需要 Java 11 或更新版本。 Therefore, you can no longer run Maven projects with JDKs 1.6, 1.7 and 1.8.因此,您不能再使用 JDK 1.6、1.7 和 1.8 运行 Maven 项目。 The minimum version is now Java 11.最低版本现在是 Java 11。

To resolve this, you may:要解决此问题,您可以:

  • Create a Freestyle project and use Invoke top-level Maven targets to invoke Maven, or create a Jenkins Pipeline project.创建一个 Freestyle 项目并使用Invoke 顶级 Maven 目标来调用 Maven,或者创建一个 Jenkins Pipeline 项目。 In both cases, using an older JDK will be possible.在这两种情况下,都可以使用较旧的 JDK。
  • Use JDK 11 but set source and target version to the older Java version.使用 JDK 11,但将源和目标版本设置为较旧的 Java 版本。 I haven't tried that though, and I believe this option may cause other trouble.不过我还没有尝试过,我相信这个选项可能会导致其他麻烦。

For further information, see also Jenkins requires Java 11 or newer and Maven Builds Fails After Upgrade有关详细信息,另请参阅Jenkins 需要 Java 11 或更新版本Maven 升级后构建失败

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Maven:构建期间的版本冲突 - maven: version conflict during build Maven安装不支持的类版本错误 - Maven-install Unsupported Class Version Error 转换过程中的一般错误:当我构建一个 android 应用程序时,Linux 中不支持的类文件主要版本 61 - General error during conversion: Unsupported class file major version 61 in Linux when I build an android app Flutter:无法编译构建文件&#39;build.gradle&#39;,语义分析期间的一般错误:不支持的类文件主要版本57 - Flutter: Could not compile build file 'build.gradle', General error during semantic analysis: Unsupported class file major version 57 Maven surefire 插件 2.22.2 构建失败,用于 Junit 5 测试用例,错误不支持 Spring Boot 中的类文件主要版本 56 - Maven surefire plugin 2.22.2 build fails for Junit 5 test cases with errror Unsupported class file major version 56 in spring boot Maven Surefire 测试失败:不支持 class 文件主要版本 61 - Maven Surefire test failed: Unsupported class file major version 61 Maven 编译器插件 不支持 class 文件主要版本 60 - Maven compiler plugin Unsupported class file major version 60 在Maven构建期间在子模块中执行类 - Execute class in submodule during maven build 在Maven构建期间如何重命名生成的类? - How to rename a generated class during a maven build? 在Jenkins构建过程中,maven-jarsigner-plugin失败,但在命令行上却没有 - maven-jarsigner-plugin fails during Jenkins build but not on command line
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM