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

Failed to getClass for org.apache.maven.plugin.source.SourceJarMojo

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • maven-plugin
    • None
    • Jenkins v.1565.3
      Maven project plugin v2.8

      We have a Maven project using the maven-source-plugin. When building the
      project on Jenkins, it shows the following warning:

      [INFO] *--- maven-jar-plugin:2.4:jar (default-jar) @ test-project ---
      *[INFO] Building jar:
      /home/jenkins/workspace/test-project/target/test-project-1.0.0-SNAPSHOT.jar[WARNING]
      Failed to getClass for org.apache.maven.plugin.source.SourceJarMojo
      

      I tested with maven-source-plugin 2.2.1, 2.3, and 2.4 and all of these
      versions exhibit the same problem.

      The problem does not appear if the project was compiled from NetBeans or command line.

      (Initially, I thought this was a Maven issue, therefore I started a thread at the Maven user's mailing list:
      http://maven-users.markmail.org/thread/jd74vnjnzfoef55e#query:+page:1+mid:no3jnbfgji2x63wj+state:results)

          [JENKINS-27372] Failed to getClass for org.apache.maven.plugin.source.SourceJarMojo

          Charles Chan added a comment -

          Charles Chan added a comment - The error message appears to originate from ExecutedMojo, but I am not sure the cause. https://github.com/jenkinsci/maven-plugin/blob/1b30d831d13ce8dce87d2b557ab3a255f0aea1fd/src/main/java/hudson/maven/ExecutedMojo.java#L110

          Harald Albers added a comment -

          I can confirm this for Maven Project Plugin 2.9 on Jenkins 1.614:

          [INFO] >>> maven-source-plugin:2.4:jar (attach-sources) @ some.project >>>
          [WARNING] Failed to getClass for org.apache.maven.plugin.source.SourceJarMojo
          [INFO] <<< maven-source-plugin:2.4:jar (attach-sources) @ some.project <<<

          Harald Albers added a comment - I can confirm this for Maven Project Plugin 2.9 on Jenkins 1.614: [INFO] >>> maven-source-plugin:2.4:jar (attach-sources) @ some.project >>> [WARNING] Failed to getClass for org.apache.maven.plugin.source.SourceJarMojo [INFO] <<< maven-source-plugin:2.4:jar (attach-sources) @ some.project <<<

          Harald Albers added a comment -

          For me the solution was to change the goal from jar to jar-no-fork:

          	<build>
          		<plugins>
          			<plugin>
          				<groupId>org.apache.maven.plugins</groupId>
          				<artifactId>maven-source-plugin</artifactId>
          				<executions>
          					<execution>
          						<id>attach-sources</id>
          						<phase>verify</phase>
          						<goals>
          							<goal>jar-no-fork</goal>
          						</goals>
          					</execution>
          				</executions>
          				<configuration>
          					<excludeResources>true</excludeResources>
          				</configuration>
          			</plugin>
          		</plugins>
          	</build>
          

          @Charles Chan please check if that also works for you and report back here.

          Harald Albers added a comment - For me the solution was to change the goal from jar to jar-no-fork : <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <executions> <execution> <id>attach-sources</id> <phase>verify</phase> <goals> <goal>jar-no-fork</goal> </goals> </execution> </executions> <configuration> <excludeResources> true </excludeResources> </configuration> </plugin> </plugins> </build> @Charles Chan please check if that also works for you and report back here.

          Harald Albers added a comment -

          Decreasing severity to Minor as the build is not affected. This issue is only about warning messages.

          Harald Albers added a comment - Decreasing severity to Minor as the build is not affected. This issue is only about warning messages.

          Alexander Kriegisch added a comment - - edited

          I can reproduce the problem and the jar-no-fork workaround works for me. But I would like to see it fixed because potentially thousands of users see those warnings (before the workaround 43 per build in my multi-module project).

          Alexander Kriegisch added a comment - - edited I can reproduce the problem and the jar-no-fork workaround works for me. But I would like to see it fixed because potentially thousands of users see those warnings (before the workaround 43 per build in my multi-module project).

          Charles Chan added a comment -

          I agree with kriegaex. If this is a issue with the Maven project plugin, I would like it to be fixed as well.
          There are too many Maven projects out there to update manually.

          Also, for people who pays attention to these things, warning message are a red flag and may indicate a potential issue.

          Charles Chan added a comment - I agree with kriegaex . If this is a issue with the Maven project plugin, I would like it to be fixed as well. There are too many Maven projects out there to update manually. Also, for people who pays attention to these things, warning message are a red flag and may indicate a potential issue.

          Might it be related to the fact that org.apache.maven.plugin.source.SourceJarMojo is forking the life cycle and the getMojoClass( md, pd ) does not found it?

          Karl-Heinz Marbaise added a comment - Might it be related to the fact that org.apache.maven.plugin.source.SourceJarMojo is forking the life cycle and the getMojoClass( md, pd ) does not found it?

          fprumbau added a comment - - edited

          I have a self-written Mojo where I see a similar message [WARNING] Failed to getClass for org.apache.maven.plugins.tap.TapRegisterMojo.

          Could anyone please explain why this message shows up and what can be done to make it go away? I looked into the code already and read everything I found on the Internet about this warning but it didn't explain the reason for this warning.

          fprumbau added a comment - - edited I have a self-written Mojo where I see a similar message [WARNING] Failed to getClass for org.apache.maven.plugins.tap.TapRegisterMojo . Could anyone please explain why this message shows up and what can be done to make it go away? I looked into the code already and read everything I found on the Internet about this warning but it didn't explain the reason for this warning.

          A similar issue occurs for me when Jenkins ver. 1.625.3.1 (CloudBees Jenkins Enterprise 15.11) runs the javadoc:javadoc goal on my project. Switching to the javadoc:javadoc-no-fork goal resolved the issue for me. Thanks to albers and charleswhchan for their comments which led me to a solution for my related issue.

          Mark Fitzgerald added a comment - A similar issue occurs for me when Jenkins ver. 1.625.3.1 (CloudBees Jenkins Enterprise 15.11) runs the javadoc:javadoc goal on my project. Switching to the javadoc:javadoc-no-fork goal resolved the issue for me. Thanks to  albers  and  charleswhchan  for their comments which led me to a solution for my related issue.

          John Yeary added a comment - - edited

          I am facing the same issue. Could we get a triage update from Jenkins development on the status? No one has been assigned to look into it.

          John Yeary added a comment - - edited I am facing the same issue. Could we get a triage update from Jenkins development on the status? No one has been assigned to look into it.

            Unassigned Unassigned
            charleswhchan Charles Chan
            Votes:
            15 Vote for this issue
            Watchers:
            21 Start watching this issue

              Created:
              Updated: