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

maven-metadata-plugin shows ClassCastException

      We use the maven-metadata-plugin for a lot of deployment jobs.
      Since we've upgraded Jenkins from 2.249.2 (LTS) to 2.277.1 (LTS) the plugin is not longer working.
      The problem still exists on 2.277.2 (LTS) and is reproducable on latest Jenkins core, too.

      The select box on each job's parameter page shows the same error message (see screenshot)

      Looking at the jenkins.log following stack trace is shown

      2021-04-26 13:06:43.841+0000 [id=2293790]       WARNING e.m.j.p.m.MavenMetadataParameterDefinition#getArtifactMetadata: Could not parse maven-metadata.xml
      
      javax.xml.bind.JAXBException: ClassCastException: attempting to cast jar:file:/var/lib/jenkins/plugins/jaxb/WEB-INF/lib/jaxb-api-2.3.0.jar!/javax/xml/bind/JAXBContext.class to jar:file:/var/lib/jenkins/plugins/jackson2-api/WEB-INF/lib/jakarta.xml.bind-api-2.3.2.jar!/jav
      ax/xml/bind/JAXBContext.class.  Please make sure that you are specifying the proper ClassLoader.     
              at javax.xml.bind.ContextFinder.handleClassCastException(ContextFinder.java:111)
      
              at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:254)
      
              at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:240)
      
              at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)
      
              at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:691)
      
              at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:632)
      
              at eu.markov.jenkins.plugin.mvnmeta.MavenMetadataParameterDefinition.getArtifactMetadata(MavenMetadataParameterDefinition.java:258)
      
              at eu.markov.jenkins.plugin.mvnmeta.MavenMetadataParameterDefinition.getVersions(MavenMetadataParameterDefinition.java:208)
      
              at jdk.internal.reflect.GeneratedMethodAccessor17819.invoke(Unknown Source)
      
              at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      
              at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      
              at org.apache.commons.jexl.util.PropertyExecutor.execute(PropertyExecutor.java:125)
      
              at org.apache.commons.jexl.util.introspection.UberspectImpl$VelGetterImpl.invoke(UberspectImpl.java:314)
      
              at org.apache.commons.jexl.parser.ASTArrayAccess.evaluateExpr(ASTArrayAccess.java:185)
      
              at org.apache.commons.jexl.parser.ASTIdentifier.execute(ASTIdentifier.java:75)
      
              at org.apache.commons.jexl.parser.ASTReference.execute(ASTReference.java:83)
      
              at org.apache.commons.jexl.parser.ASTReference.value(ASTReference.java:57)
      
              at org.apache.commons.jexl.parser.ASTReferenceExpression.value(ASTReferenceExpression.java:51)
      
              at org.apache.commons.jexl.ExpressionImpl.evaluate(ExpressionImpl.java:80)
      
              at hudson.ExpressionFactory2$JexlExpression.evaluate(ExpressionFactory2.java:74)
      
              at org.apache.commons.jelly.expression.ExpressionSupport.evaluateRecurse(ExpressionSupport.java:61)
      
              at org.apache.commons.jelly.expression.ExpressionSupport.evaluateAsIterator(ExpressionSupport.java:94)
      
              at org.apache.commons.jelly.tags.core.ForEachTag.doTag(ForEachTag.java:89)
      
              at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
      
              at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:100)
      
              at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
      
              at org.apache.commons.jelly.tags.core.OtherwiseTag.doTag(OtherwiseTag.java:41)
      
              at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
      
              at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      
              at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
      
              at org.apache.commons.jelly.tags.core.ChooseTag.doTag(ChooseTag.java:38)
      
              at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
      
              at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      
              at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:100)
      
              at org.kohsuke.stapler.jelly.CallTagLibScript$1.run(CallTagLibScript.java:99)
      
              at org.apache.commons.jelly.tags.define.InvokeBodyTag.doTag(InvokeBodyTag.java:91)
      
              at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
      
              at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:100)
      
              at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      
              at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
      
              at org.apache.commons.jelly.tags.core.WhenTag.doTag(WhenTag.java:46)
      
              at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
      
              at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      
              at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
      
              at org.apache.commons.jelly.tags.core.ChooseTag.doTag(ChooseTag.java:38)
      
              at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
      
              at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:100)
      
              at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      
              at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
      
              at org.kohsuke.stapler.jelly.CallTagLibScript.run(CallTagLibScript.java:120)
      
              at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
      
              at org.kohsuke.stapler.jelly.JellyViewScript.run(JellyViewScript.java:95)
      
              at org.kohsuke.stapler.jelly.IncludeTag.doTag(IncludeTag.java:147)
      
              at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
      
              at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:100)
      
              at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      
              at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
      
              at org.apache.commons.jelly.tags.core.ForEachTag.doTag(ForEachTag.java:150)
      
              at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
      
              at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
      
              at org.kohsuke.stapler.jelly.CallTagLibScript$1.run(CallTagLibScript.java:99)
      
              at org.apache.commons.jelly.tags.define.InvokeBodyTag.doTag(InvokeBodyTag.java:91)
      
              at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
      
              at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:100)
      
              at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:100)
      

          [JENKINS-65473] maven-metadata-plugin shows ClassCastException

          team added a comment -

          We have the very same issue after updating several plugins in jenkins 2.249.3 (but don't know their versions before).
          Don't know which plugin is responsible. Probably a combination of some plugins.
          current:

          • maven-metadata-plugin 2.0.0
          • Jackson 2 API plugin 2.12.2 (tried everything from 2.11.1 and up)

          team added a comment - We have the very same issue after updating several plugins in jenkins 2.249.3 (but don't know their versions before). Don't know which plugin is responsible. Probably a combination of some plugins. current: maven-metadata-plugin 2.0.0 Jackson 2 API plugin 2.12.2 (tried everything from 2.11.1 and up)

          Oliver Grad added a comment -

          Any ideas / news ???

          Oliver Grad added a comment - Any ideas / news ???

          Ricardo added a comment -

          Hello,

          We started facing the same issue, we are using version 2.289.3-lts-jdk11.

          The changes done were some minor updates to the plugins, basically dependencies of other plugins.

          Could the metadata changed meanwhile and have a field that is not expected? We didn't changed anything in particular. Here is an example maven-metadata.xml file:

          <metadata>
              <groupId>com.test</groupId>
              <artifactId>artifact</artifactId>
              <versioning>
                  <latest>2.24.0</latest>
                  <versions>
                      <version>2.24.0</version>
                      <version>2.24.1</version>
                      <version>2.24.2</version>
                      <version>2.23.0</version>
                  </versions>
                  <lastUpdated>20210922151422</lastUpdated>
              </versioning>
          </metadata>
          

          Thanks for the help

          Ricardo added a comment - Hello, We started facing the same issue, we are using version 2.289.3-lts-jdk11. The changes done were some minor updates to the plugins, basically dependencies of other plugins. Could the metadata changed meanwhile and have a field that is not expected? We didn't changed anything in particular. Here is an example maven-metadata.xml file: <metadata> <groupId>com.test</groupId> <artifactId>artifact</artifactId> <versioning> <latest>2.24.0</latest> <versions> <version>2.24.0</version> <version>2.24.1</version> <version>2.24.2</version> <version>2.23.0</version> </versions> <lastUpdated>20210922151422</lastUpdated> </versioning> </metadata> Thanks for the help

          Peter Goebel added a comment -

          Hello,

          is there any estimation for the solution of this issue? We would really appreciate a solution.

          Thank you very much

          Best regards

          Peter

          Peter Goebel added a comment - Hello, is there any estimation for the solution of this issue? We would really appreciate a solution. Thank you very much Best regards Peter

          Marc Rohlfs added a comment -

          Hi,

          it's been a (long) while since I've looked into my notifications from Jenkins.io. This plugin is far away from my current focus at work, and won't find any time to care about this, hence I'll offer it for adoption. Maybe one/some of You (ticket creator or commenters) would like to take over maintainership. BTW: Same happened to me some years ago: I needed some feature PRs merged (for my work back then), former maintainer didn't have time for this plugin anymore and thus I obtained maintainership and helped myself out .

          Best regards

          Marc

          Marc Rohlfs added a comment - Hi, it's been a (long) while since I've looked into my notifications from Jenkins.io. This plugin is far away from my current focus at work, and won't find any time to care about this, hence I'll offer it for adoption. Maybe one/some of You (ticket creator or commenters) would like to take over maintainership. BTW: Same happened to me some years ago: I needed some feature PRs merged (for my work back then), former maintainer didn't have time for this plugin anymore and thus I obtained maintainership and helped myself out . Best regards Marc

          Peter Goebel added a comment -

          Hi, 

          I think if the change can be done to enable the plugin for JDK 11 only then the plugin will work for long time again. Is it not possible for you exceptionally to change the prio of your work and update the plugin? I think if you do this, you will make many people happy

          Thanks and Best regards

          Peter

          Peter Goebel added a comment - Hi,  I think if the change can be done to enable the plugin for JDK 11 only then the plugin will work for long time again. Is it not possible for you exceptionally to change the prio of your work and update the plugin? I think if you do this, you will make many people happy Thanks and Best regards Peter

          Kalle Niemitalo added a comment - - edited
          javax.xml.bind.JAXBException: ClassCastException: attempting to cast jar:file:/var/lib/jenkins/plugins/jaxb/WEB-INF/lib/jaxb-api-2.3.0.jar!/javax/xml/bind/JAXBContext.class to jar:file:/var/lib/jenkins/plugins/jackson2-api/WEB-INF/lib/jakarta.xml.bind-api-2.3.2.jar!/javax/xml/bind/JAXBContext.class.  Please make sure that you are specifying the proper ClassLoader.

          To me, this looks like the Jackson 2 API plugin embeds JAXB API classes in jakarta.xml.bind-api-2.3.2.jar instead of depending on the JAXB plugin, while the Maven Metadata for CI server plugin does not explicitly depend on the JAXB plugin but gets an implied dependency anyway. Perhaps this needs to be fixed in the Jackson 2 API plugin, then.

          Kalle Niemitalo added a comment - - edited javax.xml.bind.JAXBException: ClassCastException: attempting to cast jar:file:/var/lib/jenkins/plugins/jaxb/WEB-INF/lib/jaxb-api-2.3.0.jar!/javax/xml/bind/JAXBContext.class to jar:file:/var/lib/jenkins/plugins/jackson2-api/WEB-INF/lib/jakarta.xml.bind-api-2.3.2.jar!/javax/xml/bind/JAXBContext.class. Please make sure that you are specifying the proper ClassLoader. To me, this looks like the Jackson 2 API plugin embeds JAXB API classes in jakarta.xml.bind-api-2.3.2.jar instead of depending on the JAXB plugin, while the Maven Metadata for CI server plugin does not explicitly depend on the JAXB plugin but gets an implied dependency anyway. Perhaps this needs to be fixed in the Jackson 2 API plugin, then.

          Class loaders were discussed in https://github.com/jenkinsci/jackson2-api-plugin/pull/82, although not for JAXBContext. That links to https://github.com/jenkinsci/jira-plugin/pull/353 which temporarily sets and restores the context class loader of the thread. Perhaps a similar hack would work in maven-metadata-plugin. I'm not going to try because I don't even use this plugin.

          Kalle Niemitalo added a comment - Class loaders were discussed in https://github.com/jenkinsci/jackson2-api-plugin/pull/82 , although not for JAXBContext. That links to https://github.com/jenkinsci/jira-plugin/pull/353 which temporarily sets and restores the context class loader of the thread. Perhaps a similar hack would work in maven-metadata-plugin. I'm not going to try because I don't even use this plugin.

          Marc Rohlfs added a comment -

          goebelp, that's what I like about such open source projects: you can always make yourself happy when others disappoint you

          Marc Rohlfs added a comment - goebelp , that's what I like about such open source projects: you can always make yourself happy when others disappoint you

                  at eu.markov.jenkins.plugin.mvnmeta.MavenMetadataParameterDefinition.getArtifactMetadata(MavenMetadataParameterDefinition.java:258)
                  at eu.markov.jenkins.plugin.mvnmeta.MavenMetadataParameterDefinition.getVersions(MavenMetadataParameterDefinition.java:208)
          

          The Environment field of this issue says "maven-metadata-plugin 2.0.0" but those line numbers do not match https://github.com/jenkinsci/maven-metadata-plugin/blob/maven-metadata-plugin-2.0.0/src/main/lombok/eu/markov/jenkins/plugin/mvnmeta/MavenMetadataParameterDefinition.java. Is the stack trace from 2.0.0?

          Kalle Niemitalo added a comment - at eu.markov.jenkins.plugin.mvnmeta.MavenMetadataParameterDefinition.getArtifactMetadata(MavenMetadataParameterDefinition.java:258) at eu.markov.jenkins.plugin.mvnmeta.MavenMetadataParameterDefinition.getVersions(MavenMetadataParameterDefinition.java:208) The Environment field of this issue says "maven-metadata-plugin 2.0.0" but those line numbers do not match https://github.com/jenkinsci/maven-metadata-plugin/blob/maven-metadata-plugin-2.0.0/src/main/lombok/eu/markov/jenkins/plugin/mvnmeta/MavenMetadataParameterDefinition.java . Is the stack trace from 2.0.0?

          Oliver Grad added a comment -

          kon yes, we have maven-metadata-plugin-2.0.0 installed and the logs come from the jenkins.log when we produced the problem in the UI.

          Btw.

          Jackson 2 API Plugin we've installed version 2.12.4 and in the meanwhile Core 2.303.1

           

          Oliver Grad added a comment - kon yes, we have maven-metadata-plugin-2.0.0 installed and the logs come from the jenkins.log when we produced the problem in the UI. Btw. Jackson 2 API Plugin we've installed version 2.12.4 and in the meanwhile Core 2.303.1  

          Mark Waite added a comment -

          goebelp we've created a series of five videos with steps that a new contributor can use to modernize a plugin and prepare themselves to adopt the plugin. If you'd like to try adopting this plugin, you could review the videos at:

          • Part 1 - Update parent pom, update base Jenkins version, update SCM URL
          • Part 2 - More spotbugs checks, enable dependabot, enable incremental build, enable release drafter
          • Part 3 - Convert plugin documentation to GitHub, add a "Report an Issue" link
          • Part 4 - Improve dependency management with plugin bill of materials, enable automatic plugin release
          • Part 5 - Enable and process Jenkins specific security scan

          Those videos were derived from the "Contributing to Open Source" workshop that was presented at DevOps World 2021. We are preparing a tutorial for www.jenkins.io based on that workshop and on those videos. I'd love to have your feedback on the video series and/or the workshop document. We hope it helps people solve issues that they encounter and allows them to continue contributing.

          Mark Waite added a comment - goebelp we've created a series of five videos with steps that a new contributor can use to modernize a plugin and prepare themselves to adopt the plugin. If you'd like to try adopting this plugin, you could review the videos at: Part 1 - Update parent pom, update base Jenkins version, update SCM URL Part 2 - More spotbugs checks, enable dependabot, enable incremental build, enable release drafter Part 3 - Convert plugin documentation to GitHub, add a "Report an Issue" link Part 4 - Improve dependency management with plugin bill of materials, enable automatic plugin release Part 5 - Enable and process Jenkins specific security scan Those videos were derived from the "Contributing to Open Source" workshop that was presented at DevOps World 2021. We are preparing a tutorial for www.jenkins.io based on that workshop and on those videos. I'd love to have your feedback on the video series and/or the workshop document. We hope it helps people solve issues that they encounter and allows them to continue contributing.

          Peter Goebel added a comment -

          markewaite, that sounds really great.

          Unfortunate my own capacity is limited. But I will connect other colleagues if they can contribute. 

          Peter Goebel added a comment - markewaite , that sounds really great. Unfortunate my own capacity is limited. But I will connect other colleagues if they can contribute. 

          Tobias added a comment -

          Is there any way to workaround this issue locally?

          Seems like nobody feels responsible.

          Tobias added a comment - Is there any way to workaround this issue locally? Seems like nobody feels responsible.

          Mark Waite added a comment -

          Is there a way to workaround the issue locally?

          Yes. Replace the Jenkins Maven job that is currently being used with a Jenkins Pipeline or a Jenkins Freestyle project that performs the same operations.

          Seems like nobody feels responsible.

          meyestro as stated by marcrohlfs in an earlier comment, this plugin is up for adoption. When a plugin is up for adoption, that means the current maintainer is not maintaining it and others have not yet started maintaining it. I think that makes your observation correct that nobody feels responsible for this plugin at this time.

          As an open source project, Jenkins relies on the work of volunteers who are intentionally allowed to choose how much or how little they contribute. The current maintainer, marcrohlfs, is not able to commit time to maintain the plugin and has noted that the plugin is up for adoption. If others who need this plugin are willing to spend some of their time to maintain it, they can refer to the "Contributing to Open Source" document and the tutorial videos for suggestions to prepare to adopt the plugin. Fixing this issue would be a good contribution for a new maintainer. They would benefit from the fix and others would also benefit.

          Would you like to adopt the plugin?

          Mark Waite added a comment - Is there a way to workaround the issue locally? Yes. Replace the Jenkins Maven job that is currently being used with a Jenkins Pipeline or a Jenkins Freestyle project that performs the same operations. Seems like nobody feels responsible. meyestro as stated by marcrohlfs in an earlier comment , this plugin is up for adoption . When a plugin is up for adoption, that means the current maintainer is not maintaining it and others have not yet started maintaining it. I think that makes your observation correct that nobody feels responsible for this plugin at this time. As an open source project, Jenkins relies on the work of volunteers who are intentionally allowed to choose how much or how little they contribute. The current maintainer, marcrohlfs , is not able to commit time to maintain the plugin and has noted that the plugin is up for adoption. If others who need this plugin are willing to spend some of their time to maintain it, they can refer to the "Contributing to Open Source" document and the tutorial videos for suggestions to prepare to adopt the plugin. Fixing this issue would be a good contribution for a new maintainer. They would benefit from the fix and others would also benefit. Would you like to adopt the plugin?

          Tobias added a comment -

          Sorry i got no time for adoptions. I now replaced the Parameter with Active Choice Scriptler Parameter.

          If anyone wants to to similar things here:

          def host="http://0.0.0.0:8081"
          def repository=${Repository}
          def groupId=${Group_ID}.replaceAll("\\.", "/")
          def artifactId=${ArtifactID}
          def nexus_url="${host}/repository/${repository}/${groupId}/${artifactId}/maven-metadata.xml"
          def response=nexus_url.toURL().text
          def metadata = new XmlParser().parseText(response)
          
          return metadata['versioning']['versions']['version'].collect({it.text()}).reverse()
          

           

          Tobias added a comment - Sorry i got no time for adoptions. I now replaced the Parameter with Active Choice Scriptler Parameter. If anyone wants to to similar things here: def host= "http: //0.0.0.0:8081" def repository=${Repository} def groupId=${Group_ID}.replaceAll( "\\." , "/" ) def artifactId=${ArtifactID} def nexus_url= "${host}/repository/${repository}/${groupId}/${artifactId}/maven-metadata.xml" def response=nexus_url.toURL().text def metadata = new XmlParser().parseText(response) return metadata[ 'versioning' ][ 'versions' ][ 'version' ].collect({it.text()}).reverse()  

          Oliver Grad added a comment -

          With update to Jenkins Core 2.332.3 the problem is fixed in my case.

          Oliver Grad added a comment - With update to Jenkins Core 2.332.3 the problem is fixed in my case.

          Oliver Grad added a comment -

          I suggest closing the ticket.

          Oliver Grad added a comment - I suggest closing the ticket.

          Cosmin Diga added a comment -

          "With update to Jenkins Core 2.332.3 the problem is fixed in my case."
          Do we know what fixed this issue?

          Cosmin Diga added a comment - "With update to Jenkins Core 2.332.3 the problem is fixed in my case." Do we know what fixed this issue?

            marcrohlfs Marc Rohlfs
            gradol Oliver Grad
            Votes:
            4 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: