Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-4925

Mismanagement of container lookup realm can cause type incompatibilities for plugins looking up components by string

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.1
    • 3.0.2
    • Plugins and Lifecycle
    • None

    Description

      Originally reported as MNGECLIPSE-2507 but is actually a core issue.

      To reproduce, copy plexus-build-api-0.0.6.jar into the lib directory of a Maven 3.0.1 distro and run mvn generate-sources (without clean!) on the attached project. This dies with

      INFO] Scanning for projects...
      INFO]
      INFO] ------------------------------------------------------------------------
      INFO] Building modello-regression 1.0-SNAPSHOT
      INFO] ------------------------------------------------------------------------
      INFO]
      INFO] --- modello-maven-plugin:1.4.1:java (myModel) @ modello-regression ---
      INFO] outputDirectory: M:\downloads\modello-regression\target\generated-sources\modello
      INFO] Working on model: src/main/mdo/myModel.mdo
      INFO] Generating current version: 1.0.0
      WARNING] Error contextualizing: class org.codehaus.modello.plugin.java.JavaModelloGenerator
      ava.lang.ClassCastException: org.sonatype.plexus.build.incremental.DefaultBuildContext cannot be cast to org.sonatype.plexus.build.incremental.BuildContext
             at org.codehaus.modello.plugin.AbstractModelloGenerator.contextualize(AbstractModelloGenerator.java:288)
             at org.codehaus.plexus.PlexusLifecycleManager.contextualize(PlexusLifecycleManager.java:247)
             at org.codehaus.plexus.PlexusLifecycleManager.manageLifecycle(PlexusLifecycleManager.java:223)
             at org.codehaus.plexus.PlexusLifecycleManager.manage(PlexusLifecycleManager.java:134)
             at org.sonatype.guice.plexus.binders.PlexusBeanBinder.afterInjection(PlexusBeanBinder.java:79)
             at com.google.inject.internal.MembersInjectorImpl.notifyListeners(MembersInjectorImpl.java:97)
             at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:95)
             at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:253)
             at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:949)
             at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1002)
             at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:945)
             at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:984)
             at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:48)
             at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
             at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:949)
             at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:995)
             at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:945)
             at com.google.inject.Scopes$1$1.get(Scopes.java:59)
             at org.sonatype.guice.bean.locators.LazyQualifiedBean.getValue(LazyQualifiedBean.java:66)
             at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:54)
             at java.util.AbstractMap.get(AbstractMap.java:165)
             at org.codehaus.modello.plugin.AbstractPluginManager.getPlugin(AbstractPluginManager.java:60)
             at org.codehaus.modello.core.DefaultGeneratorPluginManager.getGeneratorPlugin(DefaultGeneratorPluginManager.java:39)
             at org.codehaus.modello.core.DefaultModelloCore.generate(DefaultModelloCore.java:376)
             at org.codehaus.modello.maven.AbstractModelloGeneratorMojo.doExecute(AbstractModelloGeneratorMojo.java:266)
             at org.codehaus.modello.maven.AbstractModelloGeneratorMojo.execute(AbstractModelloGeneratorMojo.java:220)
             at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
             at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
             at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
             at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
             at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
             at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
             at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
             at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
             at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:316)
             at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
             at org.apache.maven.cli.MavenCli.execute(MavenCli.java:451)
             at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:188)
             at org.apache.maven.cli.MavenCli.main(MavenCli.java:134)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:597)
             at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
             at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
             at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
             at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
      

      Here, the DefaultBuildContext (and its contract interface BuildContext) got erroneously loaded from the core realm instead of the plugin realm.

      The error is due to bad management of the container's lookup realm and only manifests itself for the first mojo execution of a build.

      Other potentially affected plugins are those using plexus-sec-dispatcher, plexus-cipher or any other components that aren't filtered out of the plugin realm and where the component is looked up via PlexusContainer.lookup(String), i.e. without actual type as role.

      Attachments

        1. modello-regression.zip
          4 kB
          Benjamin Bentmann

        Issue Links

          Activity

            People

              bentmann Benjamin Bentmann
              bentmann Benjamin Bentmann
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: