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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Blocker
    • Resolution: Not A Defect
    • maven-plugin
    • None
    • Jenkins 2.357 on Windows Server, using JRE11

    Description

      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>

       

      Attachments

        Issue Links

          Activity

            markewaite 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/

            markewaite 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/
            lordofthemoon 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.

            lordofthemoon 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.
            jglick 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).

            jglick 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).
            lordofthemoon 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.

            lordofthemoon 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.
            jglick 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

            jglick 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

            People

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

              Dates

                Created:
                Updated:
                Resolved: