Maven
  1. Maven
  2. MNG-5042

Regression: CloningClassLoader causes StackOverflowError in groovy

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.0, 3.0.1, 3.0.2, 3.0.3
    • Fix Version/s: None
    • Component/s: Class Loading
    • Labels:
      None
    • Complexity:
      Intermediate
    • Number of attachments :
      1

      Description

      I am unable to use a groovy class as a plexus component in maven 3 because groovy's metaclass mechanism calls Introspector.getBeanInfo() in constructors which in turn calls classloader.loadClass(beanClass.getName() + BEANINFO_SUFFIX) (the class name is "FooBar$_plexus2") which in turn causes CloningClassLoader to create a new clone of the class named "FooBar$plexus2BeanInfo". When "FooBar$_plexusBeanInfo" is instantiated groovy's the meta class mechanism again calls
      Introspector.getBeanInfo() on "FooBar$__plexus2".

      Example stack trace:

      at sis.buildtools.SisMapVersionsPhase.$getStaticMetaClass(VersionsMojo.groovy)
              at sis.buildtools.SisMapVersionsPhase.<init>(VersionsMojo.groovy:692)
              at sis.buildtools.SisMapVersionsPhase$__plexus2BeanInfo.<init>(Unknown Source)
              at sun.reflect.GeneratedConstructorAccessor5.newInstance(Unknown Source)
              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
              at java.lang.Class.newInstance0(Class.java:355)
              at java.lang.Class.newInstance(Class.java:308)
              at java.beans.Introspector.instantiate(Introspector.java:1449)
              at java.beans.Introspector.findExplicitBeanInfo(Introspector.java:431)
              at java.beans.Introspector.<init>(Introspector.java:380)
              at java.beans.Introspector.getBeanInfo(Introspector.java:167)
              at groovy.lang.MetaClassImpl$15.run(MetaClassImpl.java:2940)
              at java.security.AccessController.doPrivileged(Native Method)
              at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:2938)
              at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:2921)
              at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:166)
              at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:182)
              at sis.buildtools.SisMapVersionsPhase.$getStaticMetaClass(VersionsMojo.groovy)
              at sis.buildtools.SisMapVersionsPhase.<init>(VersionsMojo.groovy:692)
              at sis.buildtools.SisMapVersionsPhase$__plexus2BeanInfo.<init>(Unknown Source)
              at sun.reflect.GeneratedConstructorAccessor5.newInstance(Unknown Source)
              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
              at java.lang.Class.newInstance0(Class.java:355)
              at java.lang.Class.newInstance(Class.java:308)
              at java.beans.Introspector.instantiate(Introspector.java:1449)
              at java.beans.Introspector.findExplicitBeanInfo(Introspector.java:431)
              at java.beans.Introspector.<init>(Introspector.java:380)
              at java.beans.Introspector.getBeanInfo(Introspector.java:167)
              at groovy.lang.MetaClassImpl$15.run(MetaClassImpl.java:2940)
              at java.security.AccessController.doPrivileged(Native Method)
              at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:2938)
              at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:2921)
              at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:166)
              at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:182)
              at sis.buildtools.SisMapVersionsPhase.$getStaticMetaClass(VersionsMojo.groovy)
              at sis.buildtools.SisMapVersionsPhase.<init>(VersionsMojo.groovy:692)
              at sis.buildtools.SisMapVersionsPhase$__plexus2BeanInfo.<init>(Unknown Source)
              at sun.reflect.GeneratedConstructorAccessor5.newInstance(Unknown Source)
              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
              at java.lang.Class.newInstance0(Class.java:355)
              at java.lang.Class.newInstance(Class.java:308)
              at java.beans.Introspector.instantiate(Introspector.java:1449)
              at java.beans.Introspector.findExplicitBeanInfo(Introspector.java:431)
              at java.beans.Introspector.<init>(Introspector.java:380)
              at java.beans.Introspector.getBeanInfo(Introspector.java:167)
              at groovy.lang.MetaClassImpl$15.run(MetaClassImpl.java:2940)
              at java.security.AccessController.doPrivileged(Native Method)
              at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:2938)
              at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:2921)
              at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:166)
              at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:182)
              at sis.buildtools.SisMapVersionsPhase.$getStaticMetaClass(VersionsMojo.groovy)
              at sis.buildtools.SisMapVersionsPhase.<init>(VersionsMojo.groovy:692)
              at sis.buildtools.SisMapVersionsPhase$__plexus2BeanInfo.<init>(Unknown Source)
              at sun.reflect.GeneratedConstructorAccessor5.newInstance(Unknown Source)

        Activity

        Hide
        Stuart McCulloch added a comment -

        If you could attach a test project that recreates the error that would be great (improves the odds of getting this fixed).

        Show
        Stuart McCulloch added a comment - If you could attach a test project that recreates the error that would be great (improves the odds of getting this fixed).
        Hide
        Stuart McCulloch added a comment -

        Patrick - any chance of getting a test/example project that shows this exception?

        Show
        Stuart McCulloch added a comment - Patrick - any chance of getting a test/example project that shows this exception?
        Hide
        Patrick Staton added a comment -

        Attached test project. After install run with something like mvn test:test-plug:test

        Show
        Patrick Staton added a comment - Attached test project. After install run with something like mvn test:test-plug:test
        Hide
        Stuart McCulloch added a comment -
        Show
        Stuart McCulloch added a comment - Fixed in https://github.com/sonatype/sisu/commit/ac276392dc8f5b3b734c830a6bcd839d22c706fd - will be available in sisu-inject 2.2.1
        Hide
        Stuart McCulloch added a comment -

        Just to close the loop; the fix is available in Maven 3.0.4, 3.0.5, and 3.1.0

        Show
        Stuart McCulloch added a comment - Just to close the loop; the fix is available in Maven 3.0.4, 3.0.5, and 3.1.0
        Hide
        Jason van Zyl added a comment -

        Fixed in 3.1.0.

        Show
        Jason van Zyl added a comment - Fixed in 3.1.0.

          People

          • Assignee:
            Unassigned
            Reporter:
            Patrick Staton
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: