Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-68878

Cannot run jaxws:wsimport from Maven project with Java 8 on 2.357

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Blocker Blocker
    • maven-plugin
    • None
    • Jenkins 2.357 on Windows Server, using JRE11

      I switched my Jenkins installation to using Java 11 recently on Windows.  I did this by changing replacing the jre folder within my Jenkins installation.

      When I upgraded to Jenkins 2.357 this morning (using the built-in 'upgrade automatically' functionality), all seemed fine initially, but when I tried to build one of my projects later, which is built with Java 8 update 312, it failed, with a ClassCastException.

      I've attached the console output from the build.

      Confirmation of local jre as being Java 11:

      C:\Windows\system32>cd \applications\Jenkins\jre
      C:\applications\Jenkins\jre>bin\java -version
      openjdk version "11.0.12" 2021-07-20 LTS
      OpenJDK Runtime Environment Corretto-11.0.12.7.1 (build 11.0.12+7-LTS)
      OpenJDK 64-Bit Server VM Corretto-11.0.12.7.1 (build 11.0.12+7-LTS, mixed mode)C:\applications\Jenkins\jre>

       

          [JENKINS-68878] Cannot run jaxws:wsimport from Maven project with Java 8 on 2.357

          Raj Bhaskar added a comment -

          Attached full list of plugins, as requested in 'filing a bug' doc

          Raj Bhaskar added a comment - Attached full list of plugins, as requested in 'filing a bug' doc

          Basil Crow added a comment -

          Per the Jenkins requires Java 11 blog post:

          For best results, it is recommended to run agents with the same version of Java as the version used on the controller. Use the Versions Node Monitors plugin to verify that agents are running a compatible version of Java.

          Ensure your agent is running the Remoting process with Java 11.

          If you are running the build on the controller's built-in node, see the Controller Isolation documentation:

          It is therefore highly advisable to not run any builds on the built-in node, instead using agents (statically configured or provided by clouds) to run builds.

          Basil Crow added a comment - Per the Jenkins requires Java 11 blog post : For best results, it is recommended to run agents with the same version of Java as the version used on the controller. Use the Versions Node Monitors plugin to verify that agents are running a compatible version of Java. Ensure your agent is running the Remoting process with Java 11. If you are running the build on the controller's built-in node, see the Controller Isolation documentation : It is therefore highly advisable to not run any builds on the built-in node, instead using agents (statically configured or provided by clouds ) to run builds.

          Basil Crow added a comment -

          I see, this is just JENKINS-40990; from the docs:

          If Jenkins detects that you are trying to use a JDK older than the controller prerequisite, it automatically reconfigure your build to use the JDK on which your agent is running. It displays in your build logs a message like :

          ERROR: ================================================================================
          ERROR: Invalid project setup: hudson/maven/AbstractMavenProcessFactory$ConfigureOriginalJDK : Unsupported major.minor version 51.0
          ERROR: JENKINS-18403JENKINS-28294 JDK 'j6' not supported to run Maven projects.
          ERROR: Maven projects have to be launched with a Java version greater or equal to the minimum version required by the controller.
          ERROR: Use the Maven JDK Toolchains (plugin) to build your maven project with an older JDK.
          ERROR: Retrying with agent Java and setting compile/test properties to point to /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/.
          ERROR: ================================================================================

          But due to the remoting upgrade in Jenkins 2.27+ this workaround doesn't work anymore if your agent or maven job is using Java < 7 - JENKINS-40990 (Because remoting is compiled for Java 7)

          Basil Crow added a comment - I see, this is just JENKINS-40990 ; from the docs: If Jenkins detects that you are trying to use a JDK older than the controller prerequisite, it automatically reconfigure your build to use the JDK on which your agent is running. It displays in your build logs a message like : ERROR: ================================================================================ ERROR: Invalid project setup: hudson/maven/AbstractMavenProcessFactory$ConfigureOriginalJDK : Unsupported major.minor version 51.0 ERROR: JENKINS-18403 JENKINS-28294 JDK 'j6' not supported to run Maven projects. ERROR: Maven projects have to be launched with a Java version greater or equal to the minimum version required by the controller. ERROR: Use the Maven JDK Toolchains (plugin) to build your maven project with an older JDK. ERROR: Retrying with agent Java and setting compile/test properties to point to /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/. ERROR: ================================================================================ But due to the remoting upgrade in Jenkins 2.27+ this workaround doesn't work anymore if your agent or maven job is using Java < 7 - JENKINS-40990 (Because remoting is compiled for Java 7)

          Basil Crow added a comment -

          I just read through the long thread from JENKINS-40990. The most important point:
           

          It's not something we can fix easily.

          I would suggest running your Maven build in a regular Freestyle or Pipeline job rather than the Maven job type to work around this long-standing bug.

          Basil Crow added a comment - I just read through the long thread from JENKINS-40990 . The most important point:   It's not something we can fix easily. I would suggest running your Maven build in a regular Freestyle or Pipeline job rather than the Maven job type to work around this long-standing bug.

          Raj Bhaskar added a comment -

          Unfortunately we've got quite a lot of projects of 'Maven' type.  I've changed all the ones I own to be Freestyle, but I'll be dependent on other people to make the change to theirs.

          I can re-upgrade to test, but I'll have to revert again until all the other projects are changed (I couldn't find a way to change the project, I had to create a new project and just copy in my config settings).

          Also, there doesn't seem to be any way to view JUnit test results in a freestyle project, the way there is in a Maven type.  Is there really no way to use a Java 8 JDK to build a project while using Java 11 to run Jenkins itself (in the Maven project type)?

          Raj Bhaskar added a comment - Unfortunately we've got quite a lot of projects of 'Maven' type.  I've changed all the ones I own to be Freestyle, but I'll be dependent on other people to make the change to theirs. I can re-upgrade to test, but I'll have to revert again until all the other projects are changed (I couldn't find a way to change the project, I had to create a new project and just copy in my config settings). Also, there doesn't seem to be any way to view JUnit test results in a freestyle project, the way there is in a Maven type.  Is there really no way to use a Java 8 JDK to build a project while using Java 11 to run Jenkins itself (in the Maven project type)?

          Mark Waite added a comment -

          Is there really no way to use a Java 8 JDK to build a project while using Java 11 to run Jenkins itself (in the Maven project type)?

          As far as I know, there is no way to build a Maven project type on a different version of Java than the Java version running on the controller. It is one of the key things that make the maven project type undesirable. We recommend a transition to Pipeline. If you can't transition to Pipeline, then transition to Freestyle.

          Freestyle projects can show JUnit test results very well. See https://plugins.jenkins.io/junit/

          Mark Waite added a comment - Is there really no way to use a Java 8 JDK to build a project while using Java 11 to run Jenkins itself (in the Maven project type)? As far as I know, there is no way to build a Maven project type on a different version of Java than the Java version running on the controller. It is one of the key things that make the maven project type undesirable. We recommend a transition to Pipeline. If you can't transition to Pipeline, then transition to Freestyle. Freestyle projects can show JUnit test results very well. See https://plugins.jenkins.io/junit/

          Raj Bhaskar added a comment -

          Hi Mark,

          Freestyle projects can show JUnit test results very well. See https://plugins.jenkins.io/junit/

          Ah, thanks!  The Maven project type did that for you automatically, and I didn't notice that as a post-build option.

          Raj Bhaskar added a comment - Hi Mark, Freestyle projects can show JUnit test results very well. See https://plugins.jenkins.io/junit/ Ah, thanks!  The Maven project type did that for you automatically, and I didn't notice that as a post-build option.

          Jesse Glick added a comment -

          there is no way to build a Maven project type on a different version of Java than the Java version running on the controller

          Again, yes you can, if you have configured the project with a Java tool which is older than the minimum version of Java supported by the controller and agent (the actual version running in either is not relevant per se). You can see from the log that the plugin correctly detected this situation and tried to recover:

          Retrying with agent Java and setting compile/test properties to point to C:\Program Files\Java\jdk1.8.0_312.
          

          And in fact it got somewhat into the build before this error from jaxws-maven-plugin:wsimport:

          -Xbootclasspath/p is no longer a supported option.
          

          While maven-plugin attempts to fix up common mojos for compilation and testing, by passing various user properties, it does not handle this one. https://www.mojohaus.org/jaxws-maven-plugin/wsimport-mojo.html#executable does not offer a user property that could be overridden, unfortunately.

          You could probably configure your agents to define Maven toolchains to pick up appropriate JDK tools for each compatible mojo (apparently including jaxws-maven-plugin:wsimport), in which case you would unset the JDK associated with the job in Jenkins. Thus, Maven itself would run with Java 11 but would use JDK 8 tools for all Java-related build steps. I am not sure whether the maven-plugin could automatically set up toolchains instead of its current trick; I have never used toolchains and am not familiar with the details.

          The Maven project type did that for you automatically

          So does https://plugins.jenkins.io/pipeline-maven/. You are strongly recommended to cease using maven-plugin and switch to Pipeline (preferably) or freestyle (if necessary).

          Jesse Glick added a comment - there is no way to build a Maven project type on a different version of Java than the Java version running on the controller Again, yes you can, if you have configured the project with a Java tool which is older than the minimum version of Java supported by the controller and agent (the actual version running in either is not relevant per se). You can see from the log that the plugin correctly detected this situation and tried to recover: Retrying with agent Java and setting compile/test properties to point to C:\Program Files\Java\jdk1.8.0_312. And in fact it got somewhat into the build before this error from jaxws-maven-plugin:wsimport : -Xbootclasspath/p is no longer a supported option. While maven-plugin attempts to fix up common mojos for compilation and testing, by passing various user properties, it does not handle this one. https://www.mojohaus.org/jaxws-maven-plugin/wsimport-mojo.html#executable does not offer a user property that could be overridden, unfortunately. You could probably configure your agents to define Maven toolchains to pick up appropriate JDK tools for each compatible mojo (apparently including jaxws-maven-plugin:wsimport ), in which case you would unset the JDK associated with the job in Jenkins. Thus, Maven itself would run with Java 11 but would use JDK 8 tools for all Java-related build steps. I am not sure whether the maven-plugin could automatically set up toolchains instead of its current trick; I have never used toolchains and am not familiar with the details. The Maven project type did that for you automatically So does https://plugins.jenkins.io/pipeline-maven/ . You are strongly recommended to cease using maven-plugin and switch to Pipeline (preferably) or freestyle (if necessary).

          Raj Bhaskar added a comment -

          for what it's worth, upgrading the jaxws-maven-plugin Maven plugin in pom.xml to v2.6, resolved the wsimport issue (as per this StackOverflow post) and the build now succeeds with Jenkins 2.357.

          Raj Bhaskar added a comment - for what it's worth, upgrading the jaxws-maven-plugin Maven plugin in pom.xml to v2.6, resolved the wsimport issue (as per this StackOverflow post ) and the build now succeeds with Jenkins 2.357.

          Jesse Glick added a comment -

          Thanks for the update lordofthemoon! I think this can be closed therefore, as it sounds like the maven-plugin is working as designed. CC aheritier olamy

          Jesse Glick added a comment - Thanks for the update lordofthemoon ! I think this can be closed therefore, as it sounds like the maven-plugin is working as designed. CC aheritier olamy

            Unassigned Unassigned
            lordofthemoon Raj Bhaskar
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: