Skip to content

Commit

Permalink
Fixed NoClassDefFoundError that causes the FromSCM extension point to…
Browse files Browse the repository at this point in the history
… fail to load.

Nov 17, 2014 6:47:10 PM hudson.ExtensionFinder$GuiceFinder$SezpozModule configure
WARNING: Failed to load com.cloudbees.jenkins.GitHubRepositoryNameContributor$FromSCM
java.lang.NoClassDefFoundError: org/jenkinsci/plugins/multiplescms/MultiSCM
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
	at java.lang.Class.privateGetPublicMethods(Class.java:2562)
	at java.lang.Class.getMethods(Class.java:1427)
	at hudson.ExtensionFinder$GuiceFinder$SezpozModule.resolve(ExtensionFinder.java:484)
	at hudson.ExtensionFinder$GuiceFinder$SezpozModule.configure(ExtensionFinder.java:511)
	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:525)
	at java.lang.Class.newInstance0(Class.java:372)
	at java.lang.Class.newInstance(Class.java:325)
	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:316)
	at hudson.ExtensionList.load(ExtensionList.java:295)
	at hudson.ExtensionList.ensureLoaded(ExtensionList.java:248)
	at hudson.ExtensionList.iterator(ExtensionList.java:138)
	at hudson.ClassicPluginStrategy.findComponents(ClassicPluginStrategy.java:309)
	at hudson.ExtensionList.load(ExtensionList.java:295)
	at hudson.ExtensionList.ensureLoaded(ExtensionList.java:248)
	at hudson.ExtensionList.size(ExtensionList.java:157)
	at java.util.AbstractCollection.isEmpty(AbstractCollection.java:86)
	at com.cloudbees.jenkins.plugins.license.PluginImpl.postInitialize(PluginImpl.java:31)
	at hudson.PluginManager$2$1$2.run(PluginManager.java:374)
	at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:146)
	at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:259)
	at jenkins.model.Jenkins$7.runTask(Jenkins.java:899)
	at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:187)
	at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
	at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: org.jenkinsci.plugins.multiplescms.MultiSCM
	at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1365)
	at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1315)
	at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1068)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
	... 43 more
  • Loading branch information
kohsuke committed Nov 18, 2014
1 parent 6bbda81 commit c9e6d85
Showing 1 changed file with 36 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.eclipse.jgit.transport.URIish;
import org.jenkinsci.plugins.multiplescms.MultiSCM;

import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -45,14 +44,8 @@ public static Collection<GitHubRepositoryName> parseAssociatedNames(AbstractProj
}


/**
* Default implementation that looks at SCM
*/
@Extension
public static class FromSCM extends GitHubRepositoryNameContributor {
@Override
public void parseAssociatedNames(AbstractProject<?, ?> job, Collection<GitHubRepositoryName> result) {

static abstract class AbstractFromSCMImpl extends GitHubRepositoryNameContributor {
protected EnvVars buildEnv(AbstractProject<?, ?> job) {
EnvVars env = new EnvVars();
for (EnvironmentContributor contributor : EnvironmentContributor.all()) {
try {
Expand All @@ -61,20 +54,10 @@ public void parseAssociatedNames(AbstractProject<?, ?> job, Collection<GitHubRep
// ignore
}
}

if (Jenkins.getInstance().getPlugin("multiple-scms") != null
&& job.getScm() instanceof MultiSCM) {
MultiSCM multiSCM = (MultiSCM) job.getScm();
List<SCM> scmList = multiSCM.getConfiguredSCMs();
for (SCM scm : scmList) {
addRepositories(scm, env, result);
}
} else {
addRepositories(job.getScm(), env, result);
}
return env;
}

private void addRepositories(SCM scm, EnvVars env, Collection<GitHubRepositoryName> r) {
protected static void addRepositories(SCM scm, EnvVars env, Collection<GitHubRepositoryName> r) {
if (scm instanceof GitSCM) {
GitSCM git = (GitSCM) scm;
for (RemoteConfig rc : git.getRepositories()) {
Expand All @@ -88,6 +71,38 @@ private void addRepositories(SCM scm, EnvVars env, Collection<GitHubRepositoryNa
}
}
}
}

/**
* Default implementation that looks at SCM
*/
@Extension
public static class FromSCM extends AbstractFromSCMImpl {
@Override
public void parseAssociatedNames(AbstractProject<?, ?> job, Collection<GitHubRepositoryName> result) {
addRepositories(job.getScm(), buildEnv(job), result);
}
}

/**
* MultiSCM support separated into a different extension point since this is an optional dependency
*/
@Extension(optional=true)
public static class FromMultiSCM extends AbstractFromSCMImpl {
// make this class fail to load if MultiSCM is not present
private MultiSCM signature() { return null; }

@Override
public void parseAssociatedNames(AbstractProject<?, ?> job, Collection<GitHubRepositoryName> result) {
if (job.getScm() instanceof MultiSCM) {
EnvVars env = buildEnv(job);

MultiSCM multiSCM = (MultiSCM) job.getScm();
List<SCM> scmList = multiSCM.getConfiguredSCMs();
for (SCM scm : scmList) {
addRepositories(scm, env, result);
}
}
}
}
}

0 comments on commit c9e6d85

Please sign in to comment.