STS / Eclipse错误:从插件调用代码时出现问题:" org.eclipse.core.resources"

时间:2016-07-13 12:22:10

标签: java eclipse gradle annotation-processing

我已经编写了一个实现com.sun.source.util.TaskListener的自定义注释和处理器。 当作为gradle构建的一部分运行时,注释处理当前有效,但是当我在STS中启用注释处理时,我收到以下错误:

Problems occurred when invoking code from plug-in: "org.eclipse.core.resources"

java.lang.NoClassDefFoundError: com/sun/source/util/TaskListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader.loadJava6FactoryClasses(AnnotationProcessorFactoryLoader.java:638)
at org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader.loadFactories(AnnotationProcessorFactoryLoader.java:577)
at org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader.getJava6FactoriesAndAttributesForProject(AnnotationProcessorFactoryLoader.java:455)
at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(IdeAnnotationProcessorManager.java:131)
at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:968)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:489)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:397)
at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:184)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:334)
at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:63)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:256)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:180)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:735)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:301)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:304)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:360)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:383)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.ClassNotFoundException: com.sun.source.util.TaskListener
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 35 more

我尝试了一些方法来解决这个问题:

  • 我已将已安装的JRE更改为指向已安装的JDK
  • 我在eclipse
  • 的JRE Definition中添加了tools.jar作为外部jar
  • 我尝试将tools.jar作为外部jar添加到已打开注释处理的项目中。
  • 我还尝试将tools.jar添加为已定义的Classpath变量

1 个答案:

答案 0 :(得分:0)

.catch(function (err) { console.log("getLawyerByUrlName() " + err) 是javac-private API。 Eclipse拥有自己的编译器。尝试在Eclipse设置中将默认编译器设置为Javac。