Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassNotFoundException: org.codehaus.groovy.runtime.DefaultGroovyMethods when opening a Groovy editor in a project without Groovy on the classpath #587

Closed
mauromol opened this issue May 17, 2018 · 16 comments
Assignees

Comments

@mauromol
Copy link

I often get errors like this:

eclipseBuildId      4.7.3.M20180330-0640
eclipseProduct      org.eclipse.platform.ide
javaRuntimeVersion  1.8.0_171-b11
osgiWs              win32
osgiOs              Windows10
osgiOsVersion       10.0.0
osgiArch            x86_64
severity            UNKNOWN


STATUS

pluginId            org.eclipse.jdt.core
pluginVersion       3.13.102.xx-201804200101-e47
code                4
severity            4
message             Failed to find Default Groovy Methods with org.codehaus.jdt.groovy.internal.compiler.GroovyClassLoaderFactory$GrapeAwareGroovyClassLoader@7435bc26
fingerprint         622910ccdf7e58a3be54c499f3553406

Exception:java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.DefaultGroovyMethods
	 at java.net.URLClassLoader.findClass(null:-1)
	 at java.lang.ClassLoader.loadClass(null:-1)
	 at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:702)
	 at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:812)
	 at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:800)
	 at org.codehaus.jdt.groovy.internal.compiler.GroovyClassLoaderFactory$GrapeAwareGroovyClassLoader.getDefaultCategories(GroovyClassLoaderFactory.java:270)
	 at org.eclipse.jdt.groovy.search.VariableScope.getCategoryNames(VariableScope.java:482)
	 at org.eclipse.jdt.groovy.search.VariableScope.getCategoryNames(VariableScope.java:470)
	 at org.eclipse.jdt.groovy.search.VariableScope.getCategoryNames(VariableScope.java:470)
	 at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.handleRequestor(TypeInferencingVisitorWithRequestor.java:2012)
	 at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.handleSimpleExpression(TypeInferencingVisitorWithRequestor.java:1993)
	 at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitClassExpression(TypeInferencingVisitorWithRequestor.java:1028)
	 at org.codehaus.groovy.ast.expr.ClassExpression.visit(ClassExpression.java:38)
	 at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitMethodCallExpression(TypeInferencingVisitorWithRequestor.java:1520)
	 at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:70)
	 at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:123)
	 at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:280)
	 at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
	 at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:147)
	 at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitConstructorOrMethod(TypeInferencingVisitorWithRequestor.java:1214)
	 at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:520)
	 at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:393)
	 at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitCompilationUnit(TypeInferencingVisitorWithRequestor.java:357)
	 at org.codehaus.groovy.eclipse.editor.highlighting.GatherSemanticReferences.findSemanticHighlightingReferences(GatherSemanticReferences.java:46)
	 at org.codehaus.groovy.eclipse.editor.highlighting.GroovySemanticReconciler.reconciled(GroovySemanticReconciler.java:236)
	 at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.reconciled(CompilationUnitEditor.java:1688)
	 at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconciled(JavaReconcilingStrategy.java:219)
	 at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconciled(JavaCompositeReconcilingStrategy.java:164)
	 at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:112)
	 at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:73)
	 at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:207)


BUNDLES

name                org.codehaus.groovy
version             2.4.15.xx-201804200101-e47

name                org.codehaus.groovy.eclipse
version             3.0.0.xx-201804200101-e47

name                org.eclipse.jdt
version             3.13.4.v20180330-0640

name                org.eclipse.jdt.ui
version             3.13.100.v20180330-0726

name                org.eclipse.jface.text
version             3.12.2.v20180112-1341

name                org.eclipse.jface
version             3.13.2.v20171022-1656


Extended Classpath Analysis                                 

The problematic package ‘org.codehaus.groovy.runtime’ may originate in the following bundles:
org.codehaus.groovy 2.4.15.xx-201804200101-e47, imported by:
    no bundle referenced on the stack trace.

They seem to be related to some background activity bound to project refresh or such, not to a specific action I start.

@eric-milles
Copy link
Member

Duplicate of #582

@eric-milles eric-milles marked this as a duplicate of #582 May 17, 2018
@mauromol
Copy link
Author

mauromol commented May 17, 2018

It can't be a duplicate of that issue, I'm not using Java 9/10 at all, as you can see from the original message (javaRuntimeVersion property).

@eric-milles
Copy link
Member

Is this error intermittent or consistently recreateable with a sequence to steps? DefaultGroovyMethods should be loaded from your project's classpath now (recent change) instead of Eclipse runtime bundles supplemented by project classpath.

@mauromol
Copy link
Author

mauromol commented May 23, 2018

I don't have exact steps to repro, it was occurring consistently on a workspace of mine. Could the problem be that Groovy is not on the project classpath? If so, I think Greclipse should fail gracefully and just disable features related to DefaultGroovyMethods (like code assist, I think)

@eric-milles
Copy link
Member

There are 2 likely possibilities I can think of:

  1. A project with no Java nature but contains Groovy (or Gradle) scripts
  2. A project with Java/Groovy natures but no Groovy on the classpath

DefaultGroovyMethods is explicitly loaded because it has an array of classes that expose Category methods. A recent change (different from one mentioned above) asks Groovy runtime for the global Category classes that have been registered and supplements with those indicated by DefaultGroovyMethods.

@eric-milles eric-milles marked this as not a duplicate of #582 May 23, 2018
@eric-milles
Copy link
Member

eric-milles commented May 23, 2018

You can view the classpath used by closing all open editors, cleaning the project, opening the Groovy Event Console and then opening one Groovy source within the project, There will be a line item in the Groovy Event Console like: AST Transforms : 10:50:11 transform classpath: ...

@mauromol
Copy link
Author

Both cases 1 and 2 may happen. For case 1, I can think of any Gradle project not applying the Java plugin (the master project of a multiproject, for instance). Case 2 is likely to be just a temporary situation (maybe while adjusting your project setup), but anyway having Eclipse complaining repeatedly with an exception is not nice.

I can't find right now what was the workspace that was exhibiting this problem consistently, but I think that the scenario is quite clear now.

@eric-milles
Copy link
Member

This goes to error log so that user may continue using eclipse without interruption but will have record of problem encountered.

@mauromol
Copy link
Author

Yes, but if you have automatic error reporting enabled it pops up repeatedly.

@mauromol
Copy link
Author

Today I encountered this problem. It happens when opening build.gradle in a plain Java project (which I think is a perfectly common scenario).

The Groovy Event Console confirms that Groovy is not on the classpath (and it should not).

As I said, this problem is very annoying when you have the automated error reporting enabled. And, if one has the option to automatically send reports to it, you'll flood the Eclipse AERI servers.

IMHO Greclipse should just fail gracefully: when Groovy is not on the classpath, assume there's no DGM methods available.

@mauromol mauromol changed the title ClassNotFoundException: org.codehaus.groovy.runtime.DefaultGroovyMethods ClassNotFoundException: org.codehaus.groovy.runtime.DefaultGroovyMethods when opening a Groovy editor on a project without Groovy on the classpath May 28, 2018
@mauromol mauromol changed the title ClassNotFoundException: org.codehaus.groovy.runtime.DefaultGroovyMethods when opening a Groovy editor on a project without Groovy on the classpath ClassNotFoundException: org.codehaus.groovy.runtime.DefaultGroovyMethods when opening a Groovy editor in a project without Groovy on the classpath May 28, 2018
@eric-milles eric-milles self-assigned this Jul 6, 2018
@wagnerma
Copy link

wagnerma commented Aug 6, 2018

I also get this:

eclipse.buildId=4.8.0.I20180611-0500
java.version=1.8.0_152
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_DE
Framework arguments: -product org.eclipse.platform.ide
Command-line arguments: -product org.eclipse.platform.ide -data E:\projects\wug\devenv48/../server_runtime48 -dev file:E:/projects/wug/devenv48/.metadata/.plugins/org.eclipse.pde.core/Launch Runtime Workbench/dev.properties -os win32 -ws win32 -arch x86_64 -clean

org.eclipse.jdt.core
Error
Mon Aug 06 13:24:26 CEST 2018
Failed to find Default Groovy Methods with org.codehaus.jdt.groovy.internal.compiler.GroovyClassLoaderFactory$GrapeAwareGroovyClassLoader@69578452

java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.DefaultGroovyMethods
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:726)
	at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:836)
	at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:824)
	at org.codehaus.jdt.groovy.internal.compiler.GroovyClassLoaderFactory$GrapeAwareGroovyClassLoader.getDefaultCategories(GroovyClassLoaderFactory.java:277)
	at org.eclipse.jdt.groovy.search.VariableScope.getCategoryNames(VariableScope.java:488)
	at org.eclipse.jdt.groovy.search.VariableScope.getCategoryNames(VariableScope.java:476)
	at org.eclipse.jdt.groovy.search.VariableScope.getCategoryNames(VariableScope.java:476)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.handleRequestor(TypeInferencingVisitorWithRequestor.java:1871)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.handleSimpleExpression(TypeInferencingVisitorWithRequestor.java:1852)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitClassExpression(TypeInferencingVisitorWithRequestor.java:889)
	at org.codehaus.groovy.ast.expr.ClassExpression.visit(ClassExpression.java:38)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitMethodCallExpression(TypeInferencingVisitorWithRequestor.java:1382)
	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:70)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:123)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:258)
	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:146)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitConstructorOrMethod(TypeInferencingVisitorWithRequestor.java:1076)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:405)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:279)
	at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitCompilationUnit(TypeInferencingVisitorWithRequestor.java:243)
	at org.codehaus.groovy.eclipse.editor.highlighting.GatherSemanticReferences.findSemanticHighlightingReferences(GatherSemanticReferences.java:46)
	at org.codehaus.groovy.eclipse.editor.highlighting.GroovySemanticReconciler.reconciled(GroovySemanticReconciler.java:236)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.reconciled(CompilationUnitEditor.java:1690)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconciled(JavaReconcilingStrategy.java:219)
	at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconciled(JavaCompositeReconcilingStrategy.java:164)
	at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:112)
	at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:73)
	at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:207)

@veita
Copy link

veita commented Aug 15, 2018

Same problem here. Eclipse regularly pops up notification windows caused by this error - very annoying.

@eric-milles
Copy link
Member

@veita Can you describe your use case a bit? What type of Groovy source are you editing in a project without the Groovy Runtime on the classpath?

@wagnerma
Copy link

wagnerma commented Aug 15, 2018

I get the error with groovy on the classpath.

@veita
Copy link

veita commented Aug 15, 2018

I get this error under various circumstances, usually with Groovy in the project classpath. The projects usually do have Java but not Groovy nature.

One way to produce the error is to create an empty Gradle project with gradle init. Then import the project as Gradle project in Eclipse. Add the dependency

dependencies {
   compile group: 'org.codehaus.groovy', name: 'groovy', version: '2.5.+'
}

Play around (opening build.gradle should suffice) and watch the Error Log view.

@Zardoz89
Copy link

Zardoz89 commented Sep 9, 2019

This keeps happening on Eclipse 4.9 with Groovy-eclipse 3.5.0

Groovy-eclipse-compiler
Identifier: org.codehaus.groovy.eclipse.feature.feature.group
version : 3.5.0.v201907112231-e1809
provider: Pivotal Software, Inc.

eclipse.buildId=4.9.0.I20180906-0745
java.vendor=Oracle Corporation
java.version=1.8.0_211
os.arch=amd64
os.name=Linux
os.version=5.0.0-27-generic
osgi.arch=x86_64
osgi.nl=es_ES
osgi.ws=gtk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants