java.lang.NoClassDefFoundError since 2016.2 update



i'm trying to add java 8 support to following plugin

but since idea 2016.2 i'm receiving java.lang.NoClassDefFoundError, on previous versions it works.


full stack trace:

org.jetbrains.jps.incremental.ProjectBuildException: Module 'felix-test' production: java.lang.NoClassDefFoundError: org/slf4j/spi/LoggerFactoryBinder
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(
at org.jetbrains.jps.cmdline.BuildSession.runBuild(
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$
at java.util.concurrent.Executors$
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$
Caused by: java.lang.NoClassDefFoundError: org/slf4j/spi/LoggerFactoryBinder
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(
at Method)
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at org.slf4j.LoggerFactory.bind(
at org.slf4j.LoggerFactory.performInitialization(
at org.slf4j.LoggerFactory.getILoggerFactory(
at org.slf4j.LoggerFactory.getLogger(
at org.slf4j.LoggerFactory.getLogger(
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(
at sun.reflect.ReflectionFactory.newFieldAccessor(
at java.lang.reflect.Field.acquireFieldAccessor(
at java.lang.reflect.Field.getFieldAccessor(
at java.lang.reflect.Field.get(
at org.apache.felix.scrplugin.annotations.FieldAnnotation.getAnnotatedFieldValue(
at org.apache.felix.scrplugin.processing.SCRAnnotationProcessor.createProperties(
at org.apache.felix.scrplugin.processing.SCRAnnotationProcessor.process(
at org.apache.felix.scrplugin.helper.AnnotationProcessorManager.process(
at org.apache.felix.scrplugin.helper.ClassScanner.processClass(
at org.apache.felix.scrplugin.helper.ClassScanner.process(
at org.apache.felix.scrplugin.helper.ClassScanner.scanSources(
at org.apache.felix.scrplugin.SCRDescriptorGenerator.execute(
at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(
... 14 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.spi.LoggerFactoryBinder
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(

Comment actions Permalink

Hi Andrey, 

Please note the "Caused by:...." stacktrace part.

It looks lilke net.chilicat.felixscr.intellij.jps.FelixModuleLevelBuilder creates an instance ScrProcessor and configures it with some classpath. The ScrProcessor then creates a classloader for the specified classpath, loads classes with this classLoader and processes loaded classes via Reflection API.

This particular exception is caused by the incomplete classpath that ScrProcessor prepared.

Hope this helps, 

Best regards, 



Comment actions Permalink

Hi, classpath looks ok, also same code works on idea 2016.1.4 but does not work on idea 2016.2 and newer.

in general classpath and classloader looks the following


final Collection<String> classPath = new LinkedHashSet<String>();


JpsJavaExtensionService service = JpsJavaExtensionService.getInstance();
JpsJavaDependenciesEnumerator enr = service.enumerateDependencies(Collections.singleton(moduleChunk.representativeTarget().getModule()));
JpsJavaDependenciesRootsEnumerator classes = enr.productionOnly().withoutSdk().recursively().classes();
for (File f : classes.getRoots()) {
// filter out non-Java classpath entries, because Felix fails processing them
if (f.getName().endsWith(".class") || f.getName().endsWith(".jar") || f.isDirectory()) {

final URL[] urls = new URL[classPath.size()];

for (int i = 0; i < classPath.size(); i++) {
urls[i] = new File(classPath.get(i)).toURI().toURL();

ClassLoader classloader = new URLClassLoader(urls, this.getClass().getClassLoader());

Comment actions Permalink

> looks ok, also same code works on idea 2016.1.4 but does not work on idea 2016.2 and newer.

Such behavior is quite possible. Take a look at how the classloader is created:

new URLClassLoader(urls, this.getClass().getClassLoader());

Parent classloader is not null and is the same loader that loaded the ScrProcessor. This means that created loader will first try to resolve classes against JPS classes and only then against the specified classpath urls.

Previous versions of IDEA might have had this missing class in the classpath, while the newer builds don't. There is also no guarantee that newer versions of JPS won't be using classes or libraries that would conflict with the classes present in the user's project being compiled.

Strictly speaking, using classloader in compiler for compiled project's class resolution is the easiest, but not the best approach, mainly because classes are loaded in compiler's JVM and compiler's environment influences the resolution result a lot. This case is a good example of such problems.

You can make class resolution process less dependent on builder's runtime, if you pass null to the classloader, but still there might be problems with cross-compilation:

- bytecode version of user's classes may be incompatible with builder's runtime;

- in general case there is no way to resolve JDK classes against the JDK that is specified in project configuration: with classloader-based approach system classes will always be resolved against the JDK that is used to run the JPS build system.

Comment actions Permalink

Thank you, make sense for me, but....


I need parent classloader as i need to pass log messages from SCR Generator to Idea messages window.

also i found the issue, org.slf4j.impl.StaticLoggerBinder was included into gradle plugin but slf4j was not in parent classpath.

Comment actions Permalink

> I need parent classloader as i need to pass log messages from SCR Generator to Idea messages window.


I would still re-consider using classloaders for user's code analysis.Sooner or later the problems I mentioned above will appear. The ASM bytecode analysis framework looks like a great choice for the task.


Please sign in to leave a comment.