2

I'm currently working on updating a maven plugin wo work in Maven 3.1 and above. It seems the plugin is working niceley, but I'm having a really hard time in updating the testsuite to the latest changes. After fighting a tough lib-version-fight to mee all seems ok, but I'm getting the following exception in my testsuite:

java.lang.ClassCastException: org.codehaus.plexus.DefaultPlexusContainer$LoggerManagerProvider cannot be cast to javax.inject.Provider
at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:46)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.SingleMethodInjector.inject(SingleMethodInjector.java:84)
at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:132)
at com.google.inject.internal.MembersInjectorImpl$1.call(MembersInjectorImpl.java:93)
at com.google.inject.internal.MembersInjectorImpl$1.call(MembersInjectorImpl.java:80)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1059)
at com.google.inject.internal.MembersInjectorImpl.injectAndNotify(MembersInjectorImpl.java:80)
at com.google.inject.internal.Initializer$InjectableReference.get(Initializer.java:174)
at com.google.inject.internal.Initializer.injectAll(Initializer.java:108)
at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:174)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
at com.google.inject.Guice.createInjector(Guice.java:96)
at com.google.inject.Guice.createInjector(Guice.java:73)
at com.google.inject.Guice.createInjector(Guice.java:62)
at org.codehaus.plexus.DefaultPlexusContainer.addPlexusInjector(DefaultPlexusContainer.java:481)
at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:206)
at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:168)
at net.flexmojos.oss.plugin.compiler.DependencyFilteringTest.initPlexus(DependencyFilteringTest.java:66)

The strange thing is that org.codehaus.plexus.DefaultPlexusContainer is part of the Maven: org.eclipse.sisu:org.eclipse.sisu.plexus:0.3.0.M1 library

final class org.codehaus.plexus.DefaultPlexusContainer.LoggerManagerProvider
    implements org.eclipse.sisu.inject.DeferredProvider<LoggerManager>

which is located in org.eclipse.sisu:org.eclipse.sisu.inject:0.3.0.M1 with

public interface org.eclipse.sisu.inject.DeferredProvider<T>
    extends com.google.inject.Provider<T>

which is located in org.sonatype.sisu:sisu-guice:3.2.4 with

public interface com.google.inject.Provider<T> extends javax.inject.Provider<T> {

So in the end a LoggerManagerProvider must be as well a com.google.inject.Provider as well as a javax.inject.Provider ... if I stop in the debugger and check:

tst instanceof com.google.inject.Provider --> True
tst instanceof javax.inject.Provider --> False 

How can this be? I guess there is some bad class-version crap going on in my VM, but I have no clue as to how I should track this down.

Chris

Christofer Dutz
  • 2,305
  • 1
  • 23
  • 34
  • some other version of jar on classpath? – SMA Oct 12 '14 at 16:28
  • can you share your pom file ? – Mzf Oct 12 '14 at 16:37
  • I just comitted my changes to my feature branch for this ... it's available at github https://github.com/chrisdutz/flexmojos/blob/feature/falcon-support/flexmojos-maven-plugin/pom.xml – Christofer Dutz Oct 12 '14 at 16:47
  • I was expecting there to be duplicate classes in my classpath but IntellJ no longer shows any duplicate sources for any of the classes involved in this problem ... and I just checked: Both Provider classes are loaded by the same classloader. – Christofer Dutz Oct 12 '14 at 16:54
  • Seems like an old version of Guice is on the classpath. – Tavian Barnes Oct 14 '14 at 14:50

1 Answers1

1

Ok ... as posted in my question the Class Hierarchy is:

org.codehaus.plexus.DefaultPlexusContainer.LoggerManagerProvider --> org.eclipse.sisu.inject.DeferredProvider --> com.google.inject.Provider --> javax.inject.Provider

I checked that my classpath contained only one org.eclipse.sisu.inject.DeferredProvider and one javax.inject.Provider ... but today I found out that one strange package provided a different implementation of com.google.inject.Provider ... after excluding this from the build, all was good again :-)

Think I have to get used to using plugins like Tattletale (http://tattletale.jboss.org/) and similar to detect stuff like that.

Christofer Dutz
  • 2,305
  • 1
  • 23
  • 34