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

Variant plugin not working when requiredClasses don't exist

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • variant-plugin
    • None

      The Variant Plugin (https://github.com/jenkinsci/variant-plugin/) is not working properly when you specify `requiredClasses` and one of them do not exists. There are two observed situations.

      • If the annotated class extends the non existent class this exception is thrown:
        WARNING: Failed to load org.jenkinsci.plugins.variant.Negative4
        java.lang.InstantiationException: java.lang.NoClassDefFoundError: org/jenkinsci/plugins/Beer
        	at net.java.sezpoz.IndexItem.element(IndexItem.java:146)
        	at hudson.ExtensionFinder$GuiceFinder$SezpozModule.configure(ExtensionFinder.java:504)
        	at com.google.inject.AbstractModule.configure(AbstractModule.java:62)
        	at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:230)
        	at com.google.inject.spi.Elements.getElements(Elements.java:103)
        	at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:136)
        	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
        	at com.google.inject.Guice.createInjector(Guice.java:96)
        	at com.google.inject.Guice.createInjector(Guice.java:73)
        	at hudson.ExtensionFinder$GuiceFinder.<init>(ExtensionFinder.java:282)
        	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        	at java.lang.Class.newInstance(Class.java:379)
        	at net.java.sezpoz.IndexItem.instance(IndexItem.java:181)
        	at hudson.ExtensionFinder$Sezpoz._find(ExtensionFinder.java:642)
        	at hudson.ExtensionFinder$Sezpoz.find(ExtensionFinder.java:617)
        	at hudson.ExtensionFinder._find(ExtensionFinder.java:151)
        	at hudson.ClassicPluginStrategy.findComponents(ClassicPluginStrategy.java:345)
        	at hudson.ExtensionList.load(ExtensionList.java:300)
        	at hudson.ExtensionList.ensureLoaded(ExtensionList.java:253)
        	at hudson.ExtensionList.iterator(ExtensionList.java:143)
        	at hudson.ClassicPluginStrategy.findComponents(ClassicPluginStrategy.java:338)
        	at hudson.ExtensionList.load(ExtensionList.java:300)
        	at hudson.ExtensionList.ensureLoaded(ExtensionList.java:253)
        	at hudson.ExtensionList.get(ExtensionList.java:158)
        	at hudson.PluginManager$PluginUpdateMonitor.getInstance(PluginManager.java:1248)
        	at hudson.maven.PluginImpl.init(PluginImpl.java:58)
        	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        	at java.lang.reflect.Method.invoke(Method.java:606)
        	at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:105)
        	at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:169)
        	at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:282)
        	at jenkins.model.Jenkins$7.runTask(Jenkins.java:886)
        	at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:210)
        	at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
        	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        	at java.lang.Thread.run(Thread.java:745)
        Caused by: java.lang.NoClassDefFoundError: org/jenkinsci/plugins/Beer
        	at java.lang.ClassLoader.defineClass1(Native Method)
        	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
        	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
        	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        	at java.security.AccessController.doPrivileged(Native Method)
        	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        	at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
        	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        	at net.java.sezpoz.IndexItem.element(IndexItem.java:134)
        	... 41 more
        Caused by: java.lang.ClassNotFoundException: org.jenkinsci.plugins.Beer
        	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        	at java.security.AccessController.doPrivileged(Native Method)
        	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        	... 55 more
        

        This is due to the fact that Guice is not treating it as optional.

      • If the class is not extended and just used inside the annotated class:
        INFO: An exception was caught and reported. Message: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
        java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
        	at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:715)
        	at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:522)
        	at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:348)
        	at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:283)
        	at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:117)
        	at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70)
        	at java.lang.Class.initAnnotationsIfNecessary(Class.java:3271)
        	at java.lang.Class.getDeclaredAnnotations(Class.java:3248)
        	at org.jenkinsci.plugins.variant.OptionalExtensionProcessor.isActive(OptionalExtensionProcessor.java:46)
        	at hudson.ExtensionFinder$GuiceFinder.isActive(ExtensionFinder.java:375)
        	at hudson.ExtensionFinder$GuiceFinder.access$400(ExtensionFinder.java:234)
        	at hudson.ExtensionFinder$GuiceFinder$SezpozModule.configure(ExtensionFinder.java:506)
        	at com.google.inject.AbstractModule.configure(AbstractModule.java:62)
        	at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:230)
        	at com.google.inject.spi.Elements.getElements(Elements.java:103)
        	at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:136)
        	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
        	at com.google.inject.Guice.createInjector(Guice.java:96)
        	at com.google.inject.Guice.createInjector(Guice.java:73)
        	at hudson.ExtensionFinder$GuiceFinder.<init>(ExtensionFinder.java:282)
        	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        	at java.lang.Class.newInstance(Class.java:379)
        	at net.java.sezpoz.IndexItem.instance(IndexItem.java:181)
        	at hudson.ExtensionFinder$Sezpoz._find(ExtensionFinder.java:642)
        	at hudson.ExtensionFinder$Sezpoz.find(ExtensionFinder.java:617)
        	at hudson.ExtensionFinder._find(ExtensionFinder.java:151)
        	at hudson.ClassicPluginStrategy.findComponents(ClassicPluginStrategy.java:345)
        	at hudson.ExtensionList.load(ExtensionList.java:300)
        	at hudson.ExtensionList.ensureLoaded(ExtensionList.java:253)
        	at hudson.ExtensionList.iterator(ExtensionList.java:143)
        	at hudson.ClassicPluginStrategy.findComponents(ClassicPluginStrategy.java:338)
        	at hudson.ExtensionList.load(ExtensionList.java:300)
        	at hudson.ExtensionList.ensureLoaded(ExtensionList.java:253)
        	at hudson.ExtensionList.get(ExtensionList.java:158)
        	at hudson.PluginManager$PluginUpdateMonitor.getInstance(PluginManager.java:1248)
        	at hudson.maven.PluginImpl.init(PluginImpl.java:58)
        	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        	at java.lang.reflect.Method.invoke(Method.java:606)
        	at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:105)
        	at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:169)
        	at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:282)
        	at jenkins.model.Jenkins$7.runTask(Jenkins.java:886)
        	at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:210)
        	at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
        	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        	at java.lang.Thread.run(Thread.java:745)
        

      This is related to this bug in the JDK http://bugs.java.com/view_bug.do?bug_id=7183985 by which an annotation with a non existent class in a value cannot be loaded.

            alobato Alvaro Lobato
            alobato Alvaro Lobato
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: