Unable to load the mojo 'enforce' in the plugin 'org.kohsuke:access-modifier-checker:1.30' due to an API incompatibility

I am facing the issue for org.kohsuke:access-modifier-checker:1.30 latest update version inside jenkins ci maven repository for java 1.8 version. This issue I am facing from latest release of https://mvnrepository.com/artifact/org.kohsuke/access-modifier-annotation?repo=jenkins-releases.
I have tried with java version 1.6,1.7,1.8,9,11,13,14,17 but still I am getting the error. I have tried with latest dependencies and plugins as well but its not working, I am attaching the error below, please help.

Execution default-enforce of goal org.kohsuke:access-modifier-checker:1.30:enforce failed: Unable to load the mojo ‘enforce’ in the plugin ‘org.kohsuke:access-modifier-checker:1.30’ due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/kohsuke/accmod/impl/EnforcerMojo has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.kohsuke:access-modifier-checker:1.30
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = /.m2/repository/org/kohsuke/access-modifier-checker/1.30/access-modifier-checker-1.30.jar
[ERROR] urls[1] = /.m2/repository/org/kohsuke/access-modifier-annotation/1.30/access-modifier-annotation-1.30.jar
[ERROR] urls[2] = /.m2/repository/org/jenkins-ci/annotation-indexer/1.17/annotation-indexer-1.17.jar
[ERROR] urls[3] = /.m2/repository/org/kohsuke/access-modifier-suppressions/1.30/access-modifier-suppressions-1.30.jar
[ERROR] urls[4] = /.m2/repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.7.0/maven-plugin-annotations-3.7.0.jar
[ERROR] urls[5] = /.m2/repository/org/kohsuke/metainf-services/metainf-services/1.9/metainf-services-1.9.jar
[ERROR] urls[6] = /.m2/repository/org/ow2/asm/asm/9.4/asm-9.4.jar
[ERROR] urls[7] = /.m2/repository/com/github/spotbugs/spotbugs-annotations/4.7.3/spotbugs-annotations-4.7.3.jar
[ERROR] urls[8] = /.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[project>com…plugins:JenkinsPlugin:-SNAPSHOT, parent: ClassRealm[maven.api, parent: null]]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR]
[ERROR] → [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] PluginContainerException - Apache Maven - Apache Software Foundation

That means you’re attempting to run Java 11 byte code in a Java 8 virtual machine. Switch to use Java 11.

Since it looks like you’re compiling the blazemeter plugin, you may want to look at the changes that I started in

Those changes are based on the “Improve a plugin” tutorial segment:

It looks like the plugin also needs

1 Like

I tried with Java 11 as well getting below error. Please help

Compilation failure: Compilation failure:
[ERROR] java.nio.file.NoSuchFileException: /Jenkins_New/new_data/jenkins-plugin/target/classes/META-INF/annotations/org.kohsuke.accmod.Restricted
[ERROR] java.nio.file.NoSuchFileException: /Jenkins_New/new_data/jenkins-plugin/target/classes/META-INF/annotations/org.kohsuke.stapler.export.ExportedBean
[ERROR] java.nio.file.NoSuchFileException: /Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/org.jenkinsci.Symbol
[ERROR] java.nio.file.NoSuchFileException: /Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/hudson.Extension
[ERROR] → [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] MojoFailureException - Apache Maven - Apache Software Foundation

See the pull request that has been updated to compile and run tests without error on Java 11.

1 Like

I tried with java 11 and ```

<jenkins.version>2.361.4</jenkins.version>

but i am getting these errors

[INFO] Scanning for projects…
[WARNING] The POM for org.jenkins-ci.tools:maven-hpi-plugin:jar:1.106 is missing, no dependency information available
[WARNING] Failed to build parent project for com.plugins:JenkinsPlugin:hpi:
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com…plugins:JenkinsPlugin:hpi
[WARNING] ‘build.pluginManagement.plugins.plugin.(groupId:artifactId)’ must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-javadoc-plugin @ line 119, column 25
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] -----------< com…plugins:JenkinsPlugin >-----------
[INFO] Building plugin
[INFO] --------------------------------[ hpi ]---------------------------------
[INFO]
[INFO] — maven-clean-plugin:2.4.1:clean (default-clean) @ JenkinsPlugin —
[INFO] Deleting /home/Jenkins_New/new_data/-jenkins-plugin/target
[INFO]
[INFO] — maven-hpi-plugin:1.106:validate (default-validate) @ JenkinsPlugin —
[INFO]
[INFO] — maven-enforcer-plugin:1.0.1:enforce (enforce-maven) @ JenkinsPlugin —
[INFO]
[INFO] — maven-enforcer-plugin:1.0.1:display-info (display-info) @ JenkinsPlugin —
[INFO] Maven Version: 3.6.0
[INFO] JDK Version: 11.0.17 normalized as: 11.0.17
[INFO] OS Info: Arch: amd64 Family: unix Name: linux Version: 5.15.0-56-generic
[INFO]
[INFO] — maven-resources-plugin:3.0.2:copy-resources (copy-resources) @ JenkinsPlugin —
[INFO] Using ‘UTF-8’ encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] — maven-localizer-plugin:1.14:generate (default) @ JenkinsPlugin —
[INFO]
[INFO] — maven-resources-plugin:3.0.2:resources (default-resources) @ JenkinsPlugin —
[INFO] Using ‘UTF-8’ encoding to copy filtered resources.
[INFO] Copying 22 resources
[INFO]
[INFO] — maven-compiler-plugin:3.7.0:compile (default-compile) @ JenkinsPlugin —
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 23 source files to /home//Jenkins_New/new_data/-jenkins-plugin/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] java.nio.file.NoSuchFileException: /home/Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/org.kohsuke.accmod.Restricted
[ERROR] java.nio.file.NoSuchFileException: /home/Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/org.kohsuke.stapler.export.ExportedBean
[ERROR] java.nio.file.NoSuchFileException: /home/Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/org.jenkinsci.Symbol
[ERROR] java.nio.file.NoSuchFileException: /home/Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/hudson.Extension
[INFO] 4 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.388 s
[INFO] Finished at: 2023-01-06T15:29:51+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project JenkinsPlugin: Compilation failure: Compilation failure:
[ERROR] java.nio.file.NoSuchFileException: /home/Jenkins_New/new_data/jenkins-plugin/target/classes/META-INF/annotations/org.kohsuke.accmod.Restricted
[ERROR] java.nio.file.NoSuchFileException: /home/Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/org.kohsuke.stapler.export.ExportedBean
[ERROR] java.nio.file.NoSuchFileException: /home//Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/org.jenkinsci.Symbol
[ERROR] java.nio.file.NoSuchFileException: /home/Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/hudson.Extension
[ERROR] → [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] MojoFailureException - Apache Maven - Apache Software Foundation

As far as I can tell, you must have not applied the changes that I made in the pull request that I included as a link in the earlier post. I’ve now pushed the change to that pull request to require Jenkins 2.361.4 and Java 11.

I’m running with:

$ mvn -version
Apache Maven 3.8.7 (b89d5959fcde851dcb1c8946a785a163f14e1e29)
Maven home: /home/mwaite/tools/apache-maven-3.8.7
Java version: 11.0.17, vendor: Eclipse Adoptium, runtime: /opt/jdk-11
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-425.3.1.el8.x86_64", arch: "amd64", family: "unix"

I have added latest changes according to you have suggested but still facing same issue

Jenkins version 2.361.4

mvn -version
Apache Maven 3.8.7 (b89d5959fcde851dcb1c8946a785a163f14e1e29)
Maven home: /opt/maven
Java version: 11.0.17, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_IN, platform encoding: UTF-8
OS name: “linux”, version: “5.15.0-56-generic”, arch: “amd64”, family: “unix”

[INFO] Scanning for projects…
[WARNING] The POM for org.jenkins-ci.tools:maven-hpi-plugin:jar:1.106 is missing, no dependency information available
[WARNING] Failed to build parent project for .plugins:JenkinsPlugin:hpi:4.18-SNAPSHOT
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com…plugins:JenkinsPlugin:hpi:4.18-SNAPSHOT
[WARNING] ‘build.pluginManagement.plugins.plugin.(groupId:artifactId)’ must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-javadoc-plugin @ line 121, column 25
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] -----------< com.plugins:JenkinsPlugin >-----------
[INFO] Building plugin 4.18-SNAPSHOT
[INFO] --------------------------------[ hpi ]---------------------------------
[INFO]
[INFO] — maven-clean-plugin:2.4.1:clean (default-clean) @ JenkinsPlugin —
[INFO]
[INFO] — maven-hpi-plugin:1.106:validate (default-validate) @ JenkinsPlugin —
[INFO]
[INFO] — maven-enforcer-plugin:1.0.1:enforce (enforce-maven) @ JenkinsPlugin —
[INFO]
[INFO] — maven-enforcer-plugin:1.0.1:display-info (display-info) @ JenkinsPlugin —
[INFO] Maven Version: 3.8.7
[INFO] JDK Version: 11.0.17 normalized as: 11.0.17
[INFO] OS Info: Arch: amd64 Family: unix Name: linux Version: 5.15.0-56-generic
[INFO]
[INFO] — maven-resources-plugin:3.0.2:copy-resources (copy-resources) @ JenkinsPlugin —
[INFO] Using ‘UTF-8’ encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] — maven-localizer-plugin:1.14:generate (default) @ JenkinsPlugin —
[INFO]
[INFO] — maven-resources-plugin:3.0.2:resources (default-resources) @ JenkinsPlugin —
[INFO] Using ‘UTF-8’ encoding to copy filtered resources.
[INFO] Copying 22 resources
[INFO]
[INFO] — maven-compiler-plugin:3.7.0:compile (default-compile) @ JenkinsPlugin —
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 23 source files to /home/lnv148/Jenkins_New/new_data/-jenkins-plugin/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] java.nio.file.NoSuchFileException: /home/lnv148/Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/org.kohsuke.accmod.Restricted
[ERROR] java.nio.file.NoSuchFileException: /home/lnv148/Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/org.jenkinsci.Symbol
[ERROR] java.nio.file.NoSuchFileException: /home/lnv148/Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/org.kohsuke.stapler.export.ExportedBean
[ERROR] java.nio.file.NoSuchFileException: /home/lnv148/Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/hudson.Extension
[INFO] 4 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.920 s
[INFO] Finished at: 2023-01-06T19:08:11+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project JenkinsPlugin: Compilation failure: Compilation failure:
[ERROR] java.nio.file.NoSuchFileException: /home/lnv148/Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/org.kohsuke.accmod.Restricted
[ERROR] java.nio.file.NoSuchFileException: /home/lnv148/Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/org.jenkinsci.Symbol
[ERROR] java.nio.file.NoSuchFileException: /home/lnv148/Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/org.kohsuke.stapler.export.ExportedBean
[ERROR] java.nio.file.NoSuchFileException: /home/lnv148/Jenkins_New/new_data/-jenkins-plugin/target/classes/META-INF/annotations/hudson.Extension
[ERROR] → [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] MojoFailureException - Apache Maven - Apache Software Foundation

1 Like

I’ll need to see your source code. Commit your local changes on a branch, push that branch to your fork of the repository, and share a link to that fork so that the exact files you’re using are visible to others.

I have added the Jenkins version, please check blazemeter-jenkins-plugin/pom.xml at d8c7d8e4fa9a90a733aa469a9ef050bd2e69d1cd · Blazemeter/blazemeter-jenkins-plugin · GitHub

1 Like

The parent pom version that is set in line 7 is wrong. See the two line correction in pom.xml lines 7 and 8 of my pull request.

The plugin bill of materials is not used in your change, but is used in my pom.xml lines 54-65 of my pull request. The plugin bill of materials provides default versions for many plugins so that you don’t need to manage the version of the credentials plugin or the workflow step api plugin.

There are 3 maven plugins defined in your pom file that are not needed. See my pull request for those examples.

1 Like