Groovysh无法以java.lang.NoSuchMethodError开头

时间:2018-10-26 08:49:13

标签: java ubuntu groovy crash

尝试在ubuntu(Ubuntu 18.04.1 LTS)上启动groovy-shell时,我遇到错误:

版本为

falk@falkpc:~$ groovysh -version
@|green Groovy Shell|@ 2.4.15

但是调用groovysh失败:

falk@falkpc:~$ groovysh 
Gtk-Message: 18:37:05.964: Failed to load module "canberra-gtk-module"
FATAL: java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer;
java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer;
    at jline.internal.InputStreamReader.<init>(InputStreamReader.java:104)
    at jline.console.ConsoleReader.setInput(ConsoleReader.java:330)
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:248)
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:236)
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:228)
    at org.codehaus.groovy.tools.shell.PatchedConsoleReader.<init>(PatchedConsoleReader.groovy:31)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
    at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:238)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:258)
    at org.codehaus.groovy.tools.shell.InteractiveShellRunner.<init>(InteractiveShellRunner.groovy:56)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
    at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77)
    at org.codehaus.groovy.runtime.callsite.ConstructorSite.callConstructor(ConstructorSite.java:45)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:238)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:258)
    at org.codehaus.groovy.tools.shell.Groovysh.run(Groovysh.groovy:588)
    at org.codehaus.groovy.tools.shell.Groovysh$run$0.callCurrent(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:169)
    at org.codehaus.groovy.tools.shell.Groovysh.run(Groovysh.groovy:574)
    at org.codehaus.groovy.tools.shell.Groovysh$run.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:136)
    at org.codehaus.groovy.tools.shell.Main.startGroovysh(Main.groovy:184)
    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.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:136)
    at org.codehaus.groovy.tools.shell.Main.main(Main.groovy:150)
    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.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:116)
    at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:138)

我已经成功使用了一段时间的安装。我不知道是什么变化导致了这种行为。

有任何想法吗?

编辑:安装后,“ Gtk-Message:...”行不再出现

sudo apt install libcanberra-gtk-module

但是,这还不能解决错误。

2 个答案:

答案 0 :(得分:1)

您需要使用Java 9运行groovysh(请参见https://github.com/blynkkk/blynk-server/issues/752

如果您不介意升级到最新版本,请执行以下操作:

# install Java 11 OpenJDK
sudo apt install openjdk-11-jdk

# update JAVA_HOME (you can get dir via: update-java-alternatives -l)
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

groovysh

答案 1 :(得分:0)

可能缺少库/依赖项:canberra-gtk-module

尝试安装相同的组件,然后再测试groovysh:

sudo apt install libcanberra-gtk-module

已编辑:

  

java.lang.NoSuchMethodError:java.nio.ByteBuffer.limit(I)

可能您正在使用JDK / JRE的不同版本/捆绑包进行编译和运行。