GroovyLanguageServer / groovy-language-server

A language server for Groovy — designed for Moonshine IDE, but may be useful in other environments
https://moonshine-ide.com/
Apache License 2.0
178 stars 59 forks source link

Setting classpath produces exception #28

Open HotelCalifornia opened 4 years ago

HotelCalifornia commented 4 years ago

I'm trying out the VSCode extension, and whenever I try to add a jar to the classpath (settings > groovy > classpath), the following exception is thrown:

Jun 28, 2020 11:08:41 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleNotification
WARNING: Notification threw an exception: {
  "jsonrpc": "2.0",
  "method": "workspace/didChangeConfiguration",
  "params": {
    "settings": {
      "groovy": {
        "java": {},
        "classpath": [
          "/home/hotel/BowlerStudio.jar"
        ]
      }
    }
  }
}
Stacktrace
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:152)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:220)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:187)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
    at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
    ... 11 more
Caused by: java.lang.NoClassDefFoundError: javafx.scene.transform.Affine
    at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveClass(AsmReferenceResolver.java:46)
    at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveNonArrayType(AsmReferenceResolver.java:79)
    at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveType(AsmReferenceResolver.java:70)
    at org.codehaus.groovy.ast.decompiled.MemberSignatureParser.createMethodNode(MemberSignatureParser.java:49)
    at org.codehaus.groovy.ast.decompiled.DecompiledClassNode$2.get(DecompiledClassNode.java:234)
    at org.codehaus.groovy.ast.decompiled.DecompiledClassNode$2.get(DecompiledClassNode.java:231)
    at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.createMethodNode(DecompiledClassNode.java:242)
    at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.lazyInitMembers(DecompiledClassNode.java:199)
    at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.getFields(DecompiledClassNode.java:92)
    at org.codehaus.groovy.classgen.VariableScopeVisitor.findClassMember(VariableScopeVisitor.java:185)
    at org.codehaus.groovy.classgen.VariableScopeVisitor.findClassMember(VariableScopeVisitor.java:205)
    at org.codehaus.groovy.classgen.VariableScopeVisitor.findClassMember(VariableScopeVisitor.java:205)
    at org.codehaus.groovy.classgen.VariableScopeVisitor.checkVariableNameForDeclaration(VariableScopeVisitor.java:250)
    at org.codehaus.groovy.classgen.VariableScopeVisitor.visitMethodCallExpression(VariableScopeVisitor.java:536)
    at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:68)
    at org.codehaus.groovy.classgen.VariableScopeVisitor.visitDeclarationExpression(VariableScopeVisitor.java:354)
    at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:89)
    at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:120)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:197)
    at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
    at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:106)
    at org.codehaus.groovy.classgen.VariableScopeVisitor.visitBlockStatement(VariableScopeVisitor.java:326)
    at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
    at org.codehaus.groovy.ast.CodeVisitorSupport.visitClosureExpression(CodeVisitorSupport.java:225)
    at org.codehaus.groovy.classgen.VariableScopeVisitor.visitClosureExpression(VariableScopeVisitor.java:449)
    at org.codehaus.groovy.ast.expr.ClosureExpression.visit(ClosureExpression.java:46)
    at org.codehaus.groovy.ast.CodeVisitorSupport.visitListOfExpressions(CodeVisitorSupport.java:324)
    at org.codehaus.groovy.ast.CodeVisitorSupport.visitTupleExpression(CodeVisitorSupport.java:229)
    at org.codehaus.groovy.ast.CodeVisitorSupport.visitArgumentlistExpression(CodeVisitorSupport.java:334)
    at org.codehaus.groovy.ast.expr.ArgumentListExpression.visit(ArgumentListExpression.java:74)
    at org.codehaus.groovy.ast.CodeVisitorSupport.visitMethodCallExpression(CodeVisitorSupport.java:182)
    at org.codehaus.groovy.classgen.VariableScopeVisitor.visitMethodCallExpression(VariableScopeVisitor.java:552)
    at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:68)
    at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:120)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:197)
    at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
    at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:106)
    at org.codehaus.groovy.classgen.VariableScopeVisitor.visitBlockStatement(VariableScopeVisitor.java:326)
    at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:110)
    at org.codehaus.groovy.classgen.VariableScopeVisitor.visitConstructorOrMethod(VariableScopeVisitor.java:521)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructor(ClassCodeVisitorSupport.java:128)
    at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1099)
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:54)
    at org.codehaus.groovy.classgen.VariableScopeVisitor.visitClass(VariableScopeVisitor.java:490)
    at org.codehaus.groovy.control.CompilationUnit$13.call(CompilationUnit.java:697)
    at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:965)
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:642)
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:618)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:595)
    at net.prominic.groovyls.GroovyServices.compile(GroovyServices.java:445)
    at net.prominic.groovyls.GroovyServices.updateClasspath(GroovyServices.java:196)
    at net.prominic.groovyls.GroovyServices.didChangeConfiguration(GroovyServices.java:176)
    ... 16 more
mattefara commented 7 months ago

I have a similar problem. The hover or completion doesn't work on external libraries. I know libraries are imported correctly because I can get an hover like the following example:

image

The error accours when I try to hover or autocomplete the imported class meanwhile the System.getenv() works.

image

I'm a newbie in web development in Java and I don't know how to use or find javax.servlet.ServletContext.

SEVERE: Internal error: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
    at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
    ... 11 more
Caused by: java.lang.NoClassDefFoundError: javax.servlet.ServletContext
    at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveClass(AsmReferenceResolver.java:46)
    at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveNonArrayType(AsmReferenceResolver.java:79)
    at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveType(AsmReferenceResolver.java:70)
    at org.codehaus.groovy.ast.decompiled.MemberSignatureParser.resolve(MemberSignatureParser.java:172)
    at org.codehaus.groovy.ast.decompiled.MemberSignatureParser.createMethodNode(MemberSignatureParser.java:64)
    at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.lambda$createConstructor$2(DecompiledClassNode.java:277)
    at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.createConstructor(DecompiledClassNode.java:283)
    at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.lazyInitMembers(DecompiledClassNode.java:238)
    at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.getDeclaredMethods(DecompiledClassNode.java:212)
    at org.codehaus.groovy.ast.ClassNode.getDeclaredMethods(ClassNode.java:882)
    at org.codehaus.groovy.ast.ClassNode.getMethods(ClassNode.java:897)
    at net.prominic.groovyls.compiler.util.GroovyASTUtils.getMethodOverloadsFromCallExpression(GroovyASTUtils.java:276)
    at net.prominic.groovyls.compiler.util.GroovyASTUtils.getMethodFromCallExpression(GroovyASTUtils.java:294)
    at net.prominic.groovyls.compiler.util.GroovyASTUtils.getMethodFromCallExpression(GroovyASTUtils.java:290)
    at net.prominic.groovyls.compiler.util.GroovyASTUtils.getDefinition(GroovyASTUtils.java:98)
    at net.prominic.groovyls.providers.HoverProvider.provideHover(HoverProvider.java:62)
    at net.prominic.groovyls.GroovyServices.hover(GroovyServices.java:219)
    ... 16 more