Maven 2 & 3

DefaultPluginManager.getConfiguredMojo() doesn't handle NoClassDefFoundError correctly

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.0.4
  • Fix Version/s: 2.1.0
  • Component/s: Plugins and Lifecycle
  • Labels:
    None
  • Complexity:
    Intermediate
  • Number of attachments :
    0

Description

If maven tries to download a file which doesn't exist and it believes there is no other place where it can get the file, you can have the situation that Maven tries to invoke a Plugin without a complete classpath. In the log, you'll see something like this:

Downloading: http://repository.codehaus.org/org/codehaus/mojo/dependency-maven-plugin/1.0/dependency-maven-plugin-1.0.pom
Downloading: http://repo1.maven.org/maven2/org/codehaus/mojo/dependency-maven-plugin/1.0/dependency-maven-plugin-1.0.jar
15K downloaded

As you can see, Maven tries to download the POM from a different site than the JAR. Now, the classpath of the JAR is incomplete because the POM is missing. Things get really nasty when Maven tries to access the plugin. You'll get:

java.lang.NoClassDefFoundError: Lorg/codehaus/plexus/archiver/manager/ArchiverManager;

which tells you exactly nothing since you have no idea who wants that class. The cause of the problem is that PlexusContainer doesn't catch errors (well, Java says you shouldn't but the user would really like to see what's going on).

My fix was to duplicate the catch in DefaultPluginManager.getConfiguredMojo() (around line 530):

catch ( NoClassDefFoundError e )

{ throw new PluginManagerException( "Unable to find the mojo '" + mojoDescriptor.getRoleHint() + "' in the plugin '" + pluginDescriptor.getPluginLookupKey() + "' because of NoClassDefFoundError:", e ); }

This way, I get at least an idea which plugin is causing the problem.

But I guess the container should be fixed to catch these errors.

Issue Links

Activity

Hide
Brett Porter added a comment -

common nuisance error - wuld be good to fix

Show
Brett Porter added a comment - common nuisance error - wuld be good to fix
Hide
John Casey added a comment -

Consolidating to 2.1.0-M1 so we can then rename to 2.1.0. We can weed out any issues we want to push to a later release from this set once we've done the consolidation.

Show
John Casey added a comment - Consolidating to 2.1.0-M1 so we can then rename to 2.1.0. We can weed out any issues we want to push to a later release from this set once we've done the consolidation.
Hide
John Casey added a comment -

It would be good if we could get even just a stack trace to start figuring out where to put this sort of code. Line 530 isn't in getConfiguredMojo() anymore, so I'm not entirely sure where to put this fix.

I'm guessing it's a whole other discussion whether we can put together an integration test for this, but it's important to try if we can.

I'm not sure we can get this done for 2.1.0, given the scant information in the issue.

Show
John Casey added a comment - It would be good if we could get even just a stack trace to start figuring out where to put this sort of code. Line 530 isn't in getConfiguredMojo() anymore, so I'm not entirely sure where to put this fix. I'm guessing it's a whole other discussion whether we can put together an integration test for this, but it's important to try if we can. I'm not sure we can get this done for 2.1.0, given the scant information in the issue.

People

Vote (2)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: