Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » ClassNotFoundException: org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl(ClassNotFoundException: org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl)
ClassNotFoundException: org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl [message #1842639] Sat, 26 June 2021 04:19
guo guo is currently offline guo guoFriend
Messages: 1
Registered: June 2021
Junior Member
I write a custom `Annotation Processor`:
    public class MyProcessor extends AbstractProcessor  {
    
        BaseProcessingEnvImpl env;
    
        @Override
        public synchronized void init(ProcessingEnvironment processingEnv) {
            String className = processingEnv.getClass().getName();
            processingEnv.getMessager().printMessage(WARNING, "class name is: " + className);
    
            if ("org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl".equals(className) ||
                "org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeBuildProcessingEnvImpl".equals(className)){

                // Trying to convert  ProcessingEnvironment to BaseProcessingEnvImpl
                env = (BaseProcessingEnvImpl) processingEnv;
            }
    
            super.init(processingEnv);
        }
    
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
            return false;
        }
    }



1. I package it to `test.jar`,
2. I add `test.jar` to <b>Eclipse project</b>.
3. I add `test.jar` to <b>Java compiler - annotation processing - factory path</b>
4. **build project**, but it throw exception:

    java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/compiler/apt/dispatch/BaseProcessingEnvImpl
    	at test.MyProcessor.init(MyProcessor.java:29)
    	at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.discoverNextProcessor(IdeAnnotationProcessorManager.java:97)
    	at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:119)
    	at org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:171)
    	at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(IdeAnnotationProcessorManager.java:138)
    	at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:950)
    	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:450)
    	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:426)
    	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:377)
    	at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:214)
    	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:309)
    	at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:79)
    	at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:272)
    	at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:187)
    	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:846)
    	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:229)
    	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:277)
    	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:330)
    	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:333)
    	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:292)
    	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:481)
    	at org.eclipse.core.internal.resources.Project$1.run(Project.java:565)
    	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2292)
    	at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:603)
    	at org.eclipse.core.internal.resources.Project.build(Project.java:116)
    	at org.eclipse.jdt.internal.ui.util.CoreUtility$BuildJob.run(CoreUtility.java:157)
    	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
    Caused by: java.lang.ClassNotFoundException: org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl
    	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:435)
    	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
    	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)



I know Eclipse use `ecj` compiler, so Why is it not loaded class `BaseProcessingEnvImpl`?
And I also try convert to `IdeBuildProcessingEnvImpl`, but get the same error.

Previous Topic:Content Assist
Next Topic:The code in my Java project isn't finding the imports from a referenced library
Goto Forum:
  


Current Time: Sun Oct 24 01:29:33 GMT 2021

Powered by FUDForum. Page generated in 0.02116 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top