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

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

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


image.png


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


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)





at org.eclipse.e4.ui.services.internal.events.UIEventHandler.lambda$0(UIEventHandler.java:38)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:236)
at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:133)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:4779)
at org.eclipse.e4.ui.workbench.swt.DisplayUISynchronize.syncExec(DisplayUISynchronize.java:34)
at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:205)
at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:203)
at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:228)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:133)
at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:75)
at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:44)
at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:55)
at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:63)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElementGen(ElementContainerImpl.java:170)
at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:188)
at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:660)
at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:624)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:787)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.bringToTop(PartServiceImpl.java:401)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1261)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:3208)
at org.eclipse.ui.internal.WorkbenchPage.lambda$9(WorkbenchPage.java:3112)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:74)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3110)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3080)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3071)
at org.eclipse.ui.ide.IDE.openEditor(IDE.java:569)
at org.eclipse.ui.ide.IDE.openEditor(IDE.java:524)
at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:367)
at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:172)
at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:288)
at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:254)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:274)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:252)
at org.eclipse.jdt.internal.ui.packageview.PackageExplorerActionGroup.handleOpen(PackageExplorerActionGroup.java:366)
at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$3.open(PackageExplorerPart.java:545)
at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(OpenAndLinkWithEditorHelper.java:48)
at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:800)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:174)
at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:797)
at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1116)
at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:296)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:331)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4243)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1060)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4060)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3632)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1154)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1045)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
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.equinox.launcher.Main.invokeFramework(Main.java:659)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
at org.eclipse.equinox.launcher.Main.run(Main.java:1467)


参看 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:


image.png


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


image.png


更详细的 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 😃



相关文章
|
15天前
|
Java Apache 开发工具
【Azure 事件中心】 org.slf4j.Logger 收集 Event Hub SDK(Java) 输出日志并以文件形式保存
【Azure 事件中心】 org.slf4j.Logger 收集 Event Hub SDK(Java) 输出日志并以文件形式保存
|
4天前
|
Arthas Java 测试技术
Java字节码文件、组成,jclasslib插件、阿里arthas工具,Java注解
Java字节码文件、组成、详解、分析;常用工具,jclasslib插件、阿里arthas工具;如何定位线上问题;Java注解
Java字节码文件、组成,jclasslib插件、阿里arthas工具,Java注解
|
3天前
|
Java API 开发者
【Java字节码操控新篇章】JDK 22类文件API预览:解锁Java底层的无限可能!
【9月更文挑战第6天】JDK 22的类文件API为Java开发者们打开了一扇通往Java底层世界的大门。通过这个API,我们可以更加深入地理解Java程序的工作原理,实现更加灵活和强大的功能。虽然目前它还处于预览版阶段,但我们已经可以预见其在未来Java开发中的重要地位。让我们共同期待Java字节码操控新篇章的到来!
|
1天前
|
算法 Java
Java 压缩文件
在Java中压缩文件是一个常见的需求,通常可以通过使用Java自带的`java.util.zip`包来实现。这个包提供了`ZipOutputStream`类来创建ZIP格式的压缩文件。以下是一个简单的示例,展示了如何将多个文件压缩到一个ZIP文件中。 ### 示例:将多个文件压缩到一个ZIP文件中 ```java import java.io.*; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; public class ZipFilesExample { public static vo
|
13天前
|
Java 应用服务中间件 HSF
Java应用结构规范问题之配置Logback以仅记录错误级别的日志到一个滚动文件中的问题如何解决
Java应用结构规范问题之配置Logback以仅记录错误级别的日志到一个滚动文件中的问题如何解决
|
13天前
|
Java 程序员
Java系统中的错误码设计问题之实现一个基于properties文件的错误消息管理系统如何解决
Java系统中的错误码设计问题之实现一个基于properties文件的错误消息管理系统如何解决
11 1
|
3天前
|
关系型数据库 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应用提供了一个坚实的基础。
12 0
|
9天前
|
Java
java判断文件内容不为空
请注意,在实际的生产环境中,处理文件时需要考虑异常处理。在上述代码中,如果在文件读取过程中发生 `IOException`,则会被捕获,并在控制台打印堆栈跟踪信息。在更复杂的系统中,可能还需要更精细的异常处理策略。
20 0
|
15天前
|
Java Linux C++
【Azure 应用服务】App Service For Linux 部署Java Spring Boot应用后,查看日志文件时的疑惑
【Azure 应用服务】App Service For Linux 部署Java Spring Boot应用后,查看日志文件时的疑惑
|
16天前
|
存储 Java 开发工具
【Azure Developer】VS Code运行Java 版Azure Storage SDK操作Blob (新建Container, 上传Blob文件,下载及清理)
【Azure Developer】VS Code运行Java 版Azure Storage SDK操作Blob (新建Container, 上传Blob文件,下载及清理)

推荐镜像

更多