Eclipse 安装了 Groovy 开发插件之后,双击打不开 .java 文件了

简介: Eclipse 安装了 Groovy 开发插件之后,双击打不开 .java 文件了

我在 Eclipse 里打开我的 Java 项目,双击一个 .java 文件,遇到错误消息:Failed to create the part's control



错误的调用栈如下图所示:


java.lang.NoClassDefFoundError: org/codehaus/groovy/eclipse/editor/GroovyAwareFoldingStructureProvider
at org.codehaus.groovy.eclipse.GroovyPlugin$1.getCurrentFoldingProvider(GroovyPlugin.java:182)
at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.createSourceViewer(JavaEditor.java:1891)
at org.eclipse.ui.texteditor.AbstractTextEditor.createPartControl(AbstractTextEditor.java:3369)
at org.eclipse.ui.texteditor.StatusTextEditor.createPartControl(StatusTextEditor.java:64)
at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.createPartControl(AbstractDecoratedTextEditor.java:454)
at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.createPartControl(JavaEditor.java:3093)
at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.createPartControl(CompilationUnitEditor.java:1521)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:158)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor.createPartControl(CompatibilityEditor.java:96)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:365)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:995)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:960)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalInject(InjectorImpl.java:140)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:403)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:330)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:202)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:91)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:60)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:42)
at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:132)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:994)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:658)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:762)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:727)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:711)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.lambda$0(PartServiceImpl.java:105)


java.lang.NoClassDefFoundError: org/codehaus/groovy/eclipse/editor/GroovyAwareFoldingStructureProvider
at org.codehaus.groovy.eclipse.GroovyPlugin$1.getCurrentFoldingProvider(GroovyPlugin.java:182)
at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.createSourceViewer(JavaEditor.java:1891)
at org.eclipse.ui.texteditor.AbstractTextEditor.createPartControl(AbstractTextEditor.java:3369)
at org.eclipse.ui.texteditor.StatusTextEditor.createPartControl(StatusTextEditor.java:64)
at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.createPartControl(AbstractDecoratedTextEditor.java:454)
at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.createPartControl(JavaEditor.java:3093)
at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.createPartControl(CompilationUnitEditor.java:1521)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:158)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor.createPartControl(CompatibilityEditor.java:96)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:365)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:995)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:960)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalInject(InjectorImpl.java:140)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:403)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:330)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:202)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:91)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:60)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:42)
at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:132)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:994)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:658)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:762)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:727)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:711)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.lambda$0(PartServiceImpl.java:105)


参看 Eclipse 的 bug 列表:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=577806


It seems that you have installed the Groovy Development tools, or at least some of the plugins of that project.



Their project overrides the getCurrentFoldingProvider method using reflection, that causes this error.


https://github.com/groovy/groovy-eclipse/blob/master/ide/org.codehaus.groovy.eclipse.ui/src/org/codehaus/groovy/eclipse/GroovyPlugin.java#L177


This issue is reported at the Groovy Eclipse plugin:


https://github.com/groovy/groovy-eclipse/issues/1319


如果 Eclipse 安装了 Eclipse Groovy Development Tools 和 Groovy compiler 3.0, 就会出现这个错误,因为 Groovy 插件通过 Java reflection 机制,复写了 getCurrentFoldingProvider,导致的 bug:



我把上图所示的两个黄色插件从 Eclipse 里卸载,就又可以重新打开 Java 文件了:




更详细的 Groovy plugin 信息:


Pivotal Software, Inc. Apache Groovy 2.5.14.v202103311613-e2103-RELEASE org.codehaus.groovy

Pivotal Software, Inc. Groovy Ant support 4.1.0.v202103311613-e2103-RELEASE org.codehaus.groovy.eclipse.ant

Pivotal Software, Inc. Groovy AST Views 4.1.0.v202103311613-e2103-RELEASE org.codehaus.groovy.eclipse.astviews

Pivotal Software, Inc. Groovy Code Assist 4.1.0.v202103311613-e2103-RELEASE org.codehaus.groovy.eclipse.codeassist

Pivotal Software, Inc. Groovy Code Browsing 4.1.0.v202103311613-e2103-RELEASE org.codehaus.groovy.eclipse.codebrowsing

Pivotal Software, Inc. Groovy Compiler Resolver 4.1.0.v202103311613-e2103-RELEASE org.codehaus.groovy.eclipse.compilerResolver

Pivotal Software, Inc. Groovy Core 4.1.0.v202103311613-e2103-RELEASE org.codehaus.groovy.eclipse.core

Pivotal Software, Inc. Groovy DSL support 4.1.0.v202103311613-e2103-RELEASE org.codehaus.groovy.eclipse.dsl

Pivotal Software, Inc. Groovy-Eclipse 4.1.0.v202103311613-e2103-RELEASE org.codehaus.groovy.eclipse

Pivotal Software, Inc. Groovy-Eclipse integration 4.1.0.v202103311613-e2103-RELEASE org.eclipse.jdt.groovy.core

Pivotal Software, Inc. Groovy Quick Fix 4.1.0.v202103311613-e2103-RELEASE org.codehaus.groovy.eclipse.quickfix

Pivotal Software, Inc. Groovy Refactoring 4.1.0.v202103311613-e2103-RELEASE org.codehaus.groovy.eclipse.refactoring

Pivotal Software, Inc. Groovy UI 4.1.0.v202103311613-e2103-RELEASE org.codehaus.groovy.eclipse.ui


如果想保留 Groovy 插件,解决方案参考如下:


In our project (Apache OFBiz) we still use Groovy 2.5.11, so I tried to install GDT 3.5.0. Eclipse refused and suggested something else. It worked. I have now a mix of installed versions (3 4.50 and 1 4.40) but at least it works 😃



相关文章
|
2月前
|
Java 关系型数据库 MySQL
"解锁Java Web传奇之旅:从JDK1.8到Tomcat,再到MariaDB,一场跨越数据库的冒险安装盛宴,挑战你的技术极限!"
【8月更文挑战第19天】在Linux上搭建Java Web应用环境,需安装JDK 1.8、Tomcat及MariaDB。本指南详述了使用apt-get安装OpenJDK 1.8的方法,并验证其版本。接着下载与解压Tomcat至`/usr/local/`目录,并启动服务。最后,通过apt-get安装MariaDB,设置基本安全配置。完成这些步骤后,即可验证各组件的状态,为部署Java Web应用打下基础。
42 1
|
9天前
|
Java Linux Windows
如何安装java环境|4-17
如何安装java环境|4-17
|
2月前
|
前端开发 Java Maven
【前端学java】全网最详细的maven安装与IDEA集成教程!
【8月更文挑战第12天】全网最详细的maven安装与IDEA集成教程!
71 2
【前端学java】全网最详细的maven安装与IDEA集成教程!
|
2月前
|
SQL Java 关系型数据库
实时数仓 Hologres产品使用合集之如何安装和使用Java SDK
实时数仓Hologres是阿里云推出的一款高性能、实时分析的数据库服务,专为大数据分析和复杂查询场景设计。使用Hologres,企业能够打破传统数据仓库的延迟瓶颈,实现数据到决策的无缝衔接,加速业务创新和响应速度。以下是Hologres产品的一些典型使用场景合集。
|
1月前
|
关系型数据库 Java MySQL
"解锁Java Web传奇之旅:从JDK1.8到Tomcat,再到MariaDB,一场跨越数据库的冒险安装盛宴,挑战你的技术极限!"
【9月更文挑战第6天】在Linux环境下安装JDK 1.8、Tomcat和MariaDB是搭建Java Web应用的关键步骤。本文详细介绍了使用apt-get安装OpenJDK 1.8、下载并配置Tomcat,以及安装和安全设置MariaDB(MySQL的开源分支)的方法。通过这些步骤,您可以快速构建一个稳定、高效的开发和部署环境,并验证各组件是否正确安装和运行。这为您的Java Web应用提供了一个坚实的基础。
37 0
|
7天前
|
安全 Java 调度
Java编程时多线程操作单核服务器可以不加锁吗?
Java编程时多线程操作单核服务器可以不加锁吗?
21 2
|
11天前
|
存储 缓存 Java
java线程内存模型底层实现原理
java线程内存模型底层实现原理
java线程内存模型底层实现原理
|
16天前
|
缓存 Java 应用服务中间件
Java虚拟线程探究与性能解析
本文主要介绍了阿里云在Java-虚拟-线程任务中的新进展和技术细节。
|
13天前
|
Java 开发者
Java中的多线程基础与应用
【9月更文挑战第22天】在Java的世界中,多线程是一块基石,它支撑着现代并发编程的大厦。本文将深入浅出地介绍Java中多线程的基本概念、创建方法以及常见的应用场景,帮助读者理解并掌握这一核心技术。
|
9天前
|
Java 调度
Java-Thread多线程的使用
这篇文章介绍了Java中Thread类多线程的创建、使用、生命周期、状态以及线程同步和死锁的概念和处理方法。
Java-Thread多线程的使用

推荐镜像

更多
下一篇
无影云桌面