Can't initialize javac processor due to (most likely) a class loader problem

2,545 views
Skip to first unread message

Earle

unread,
Apr 18, 2016, 2:49:32 PM4/18/16
to Project Lombok
The project (https://github.com/sakaiproject/sakai) I am working on has used lombok for quite some time and its use has grown considerably.

While doing some pom reorganization I decided to globally add lombok to every module in the build (we have ~500 modules)!

You can understand why setting some dependencies globally would be important!

When adding lombok globally this one project began to throw the stack below. This stack only appears when running tests, and although the tests pass stacks like this are emitted. One thing to know is that this particular module doesn't use lombok at all!

mvn-compiler-plugin is 3.5.1
mvn-surefire-plugin is 2.9.1
jdk 1.8.0_77

Running org.sakaiproject.util.ComponentsLoaderTest
/var/folders/7f/lzbvy_8d30730ngpywcvl5800000gn/T/components/sakai-69v6enfj-pack/src/org/sakaiproject/util/ServiceImpl69v6enfj.java:2: warning: Can't initialize javac processor due to (most likely) a class loader problem: java.lang.NoClassDefFoundError: com/sun/tools/javac/processing/JavacProcessingEnvironment
public class ServiceImpl69v6enfj { }
       ^
  at lombok.javac.apt.LombokProcessor.init(LombokProcessor.java:84)
  at lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:87)
  at lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:141)
  at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.init(AnnotationProcessor.java:53)
  at com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.<init>(JavacProcessingEnvironment.java:500)
  at com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.next(JavacProcessingEnvironment.java:597)
  at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:690)
  at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
  at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
  at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
  at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
  at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
  at com.sun.tools.javac.main.Main.compile(Main.java:523)
  at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
  at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
  at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:67)
  at org.sakaiproject.util.Compiler.compileWithJavaxCompiler(Compiler.java:103)
  at org.sakaiproject.util.Compiler.compile(Compiler.java:57)
  at org.sakaiproject.util.Component.compile(Component.java:256)
  at org.sakaiproject.util.Component.generate(Component.java:163)
  at org.sakaiproject.util.ComponentBuilder.buildComponent(ComponentBuilder.java:45)
  at org.sakaiproject.util.ComponentBuilder.buildComponent(ComponentBuilder.java:35)
  at org.sakaiproject.util.ComponentsLoaderTest.testLoadDispatch(ComponentsLoaderTest.java:190)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
  at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
  at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
  at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
  at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
  at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
  at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
  at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
  at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
  Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.processing.JavacProcessingEnvironment
  at java.lang.ClassLoader.findClass(ClassLoader.java:530)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at lombok.launch.ShadowClassLoader.loadClass(ShadowClassLoader.java:418)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  ... 49 more

Earle

unread,
Apr 19, 2016, 2:57:03 PM4/19/16
to Project Lombok
I've added the following to the maven-surefire-plugin which is responsible for running tests:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
      <systemPropertyVariables>
        <!-- disable lombok during tests -->
        <lombok.disable>true</lombok.disable>
      </systemPropertyVariables>
    </configuration>
</plugin>

I consider this a temporary fix, should still address the underlying issue.
Reply all
Reply to author
Forward
0 new messages