GGTS (Eclipse) 和 JAVA 1.8 中的 JVM 不兼容

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28880781/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 06:59:27  来源:igfitidea点击:

Incompatible JVM in GGTS (Eclipse) and JAVA 1.8

javaeclipseggts

提问by Al-Punk

Having some problem with running a grails application in GGTS (eclipse) due to upgrade to Java 1.8.

由于升级到 Java 1.8,在 GGTS (eclipse) 中运行 grails 应用程序时遇到一些问题。

The stack starts with:

堆栈开始于:

Mar 05, 2015 3:51:31 PM org.springsource.loaded.jvm.JVM copyMethod
SEVERE: Problems copying method. Incompatible JVM?
java.lang.reflect.InvocationTargetException
    at sun.reflect.GeneratedMethodAccessor91.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springsource.loaded.jvm.JVM.copyMethod(JVM.java:134)
    at org.springsource.loaded.ri.OriginalClassInvoker.createJavaMethod(OriginalClassInvoker.java:68)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlClassGetDeclaredMethods(ReflectiveInterceptor.java:151)
    at org.codehaus.groovy.reflection.CachedClass.run(CachedClass.java:84)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.codehaus.groovy.reflection.CachedClass.initValue(CachedClass.java:81)
...
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
    at org.codehaus.groovy.grails.cli.support.GrailsStarter.rootLoader(GrailsStarter.java:236)
    at org.codehaus.groovy.grails.cli.support.GrailsStarter.main(GrailsStarter.java:264)
Caused by: java.lang.IllegalArgumentException: Can not copy a non-root Method
    at java.lang.reflect.Method.copy(Method.java:151)
    ... 280 more

I used to run the same application in Java 1.7. My colleagues upgraded to 1.8 and no longer able to run it.

我曾经在 Java 1.7 中运行相同的应用程序。我的同事升级到 1.8 并且不再能够运行它。

I tested with SUN JDK and now I am on OpenJDK again and that does not help Current JDK openjdk version "1.8.0_40"

我使用 SUN JDK 进行了测试,现在我再次使用 OpenJDK,但这无济于事 当前 JDK openjdk 版本“1.8.0_40”

JAVA_HOME, JAVA_PATH and any other variable seems to point to the correct JDK installation. I have removed all the previous (JDK 1.6 & 1.7 from the OS to be sure that there is no reference to them).

JAVA_HOME、JAVA_PATH 和任何其他变量似乎都指向正确的 JDK 安装。我已经删除了以前的所有内容(从操作系统中删除了 JDK 1.6 和 1.7,以确保没有对它们的引用)。

For some reason GGTS still complains for a wrong JVM. I understand the error might be related to a compiler 1.7 trying to compile files in the 1.8, but I am not sure where this reference is comming from in eclipse.

出于某种原因,GGTS 仍然抱怨 JVM 错误。我知道该错误可能与编译器 1.7 试图在 1.8 中编译文件有关,但我不确定此引用在 eclipse 中的来源。

My Eclipse installation information lists the following under Java:

我的Eclipse安装信息在Java下列出了​​以下内容:

-vm
/usr/lib64/jvm/jre-1.8.0-openjdk/bin/java
eclipse.home.location=file:/home/arb/dev/applications/ggts-3.6.3.SR1/
eclipse.launcher=/home/arb/dev/applications/ggts-3.6.3.SR1/GGTS
eclipse.launcher.name=GGTS
[email protected]/../p2
eclipse.p2.profile=DefaultProfile
eclipse.product=org.springsource.ggts.ide
eclipse.startTime=1425566898624
eclipse.stateSaveDelayInterval=30000
eclipse.vm=/usr/lib64/jvm/jre-1.8.0-openjdk/bin/java
eclipse.vmargs=-Dgrails.console.enable.interactive=false
-Dgrails.console.enable.terminal=false
-Djline.terminal=jline.UnsupportedTerminal
-Dgrails.console.class=grails.build.logging.GrailsEclipseConsole
-Dosgi.requiredJavaVersion=1.6
-Xms60m
-Xmx1024m

采纳答案by Fernando

It's a problem related to jdk8u40, go back to jdku31. It works in that version. I'm running into the same problem both in windows and linux environments.

是jdk8u40的问题,回到jdku31。它适用于该版本。我在 windows 和 linux 环境中都遇到了同样的问题。

回答by penguin

Version 1.8.0_40 and 1.8.0_45 has breaking updates with grails. Spring can not copy non-Root methods.

版本 1.8.0_40 和 1.8.0_45 对 grails 进行了重大更新。Spring 不能复制非 Root 方法。

Since the initial posting a workaround has been developed.

自最初发布以来,已经开发了一种解决方法。

aclement commented on Mar 5 Here is the build: http://repo.spring.io/libs-snapshot-local/org/springframework/springloaded/1.2.2.BUILD-SNAPSHOT/springloaded-1.2.2.BUILD-SNAPSHOT.jar

To test it under grails, what I do is go into the grails folder: grails-2.5.0/lib/org.springframework/springloaded/jars

I then rename the spring loaded jar that is there and put in a symlink to the jar above. It used to be that you could just modify the startGrails script to point to the new version, but now due to the forking I find you need to do the symlink thing. Or drop that jar into this folder and rename it to match the expectations of grails (rename it from springloaded-1.2.2.BUILD-SNAPSHOT.jar to springloaded-1.2.0.RELEASE.jar)

克莱门特在 3 月 5 日评论这是构建:http://repo.spring.io/libs-snapshot-local/org/springframework/springloaded/1.2.2.BUILD-SNAPSHOT/springloaded-1.2.2.BUILD-SNAPSHOT 。罐

为了在 grails 下测试它,我要做的是进入 grails 文件夹:grails-2.5.0/lib/org.springframework/springloaded/jars

然后我重命名那里的弹簧罐,并在上面的罐子中放置一个符号链接。过去,您只需修改 startGrails 脚本以指向新版本,但现在由于分叉,我发现您需要执行符号链接。或者将该 jar 放入此文件夹并重命名以符合 grails 的期望(将其从 springloaded-1.2.2.BUILD-SNAPSHOT.jar 重命名为 springloaded-1.2.0.RELEASE.jar)

If you want to rollback instead

如果你想回滚

Grails is natively supported in 1.8.0_25, 1.8.0_31

1.8.0_25、1.8.0_31 原生支持 Grails

http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html#jdk-8u25-oth-JPR

http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html#jdk-8u25-oth-JPR

Once you have a compatible java version clean your grails project. Ensure that your java path variables are set to point to your expected version.

一旦你有一个兼容的 java 版本,清理你的 grails 项目。确保您的 java 路径变量设置为指向您的预期版本。

set JAVA_HOME=C:\java\jdk1.8.0_25
set PATH=%JAVA_HOME%\bin;%PATH%;

回答by TriumphST

I am running Grails 2.4.3 and also had problems moving from jdk1.8.0_31 to jdk1.8.0_40 and had to go back to jdk1.8.0_31

我正在运行 Grails 2.4.3 并且从 jdk1.8.0_31 移动到 jdk1.8.0_40 也有问题,不得不回到 jdk1.8.0_31

Loading Grails 2.4.3
...
SEVERE: Problems copying method. Incompatible JVM?
java.lang.reflect.InvocationTargetException
...
Caused by: java.lang.IllegalArgumentException: Can not copy a non-root Method
at java.lang.reflect.Method.copy(Method.java:151)

回答by guanche

Root cause, work-arounds and news on fixes here: https://github.com/spring-projects/spring-loaded/issues/98

根本原因、变通方法和修复新闻在这里:https: //github.com/spring-projects/spring-loaded/issues/98

回答by dustmachine

I updated my springloaded jar to version 1.2.4.BUILD-SNAPSHOT (from 1.2.1) and that resolved the issue. (Latest version can be found in the Spring repo)

我将 springloaded jar 更新到版本 1.2.4.BUILD-SNAPSHOT(从 1.2.1 开始)并解决了问题。(最新版本可以在Spring repo 中找到)

  1. Go to your local Grails lib directory to find springloaded jar. For me that was /usr/local/Cellar/grails/2.4.4/libexec/lib/org.springframework/springloaded/jars/
  2. remove existing 1.2.1 jars (I removed pom file, too, but not necessary)
  3. download latest springloaded jar and place into the jarssubdir: wget http://repo.spring.io/libs-snapshot-local/org/springframework/springloaded/1.2.4.BUILD-SNAPSHOT/springloaded-1.2.4.BUILD-SNAPSHOT.jar
  1. 转到您本地的 Grails lib 目录以查找 springloaded jar。对我来说那是/usr/local/Cellar/grails/2.4.4/libexec/lib/org.springframework/springloaded/jars/
  2. 删除现有的 1.2.1 jar(我也删除了 pom 文件,但不是必需的)
  3. 下载最新的 springloaded jar 并放入jars子目录: wget http://repo.spring.io/libs-snapshot-local/org/springframework/springloaded/1.2.4.BUILD-SNAPSHOT/springloaded-1.2.4.BUILD-SNAPSHOT.jar

After doing that, everything works. (Clues used from previous answer: https://github.com/spring-projects/spring-loaded/issues/98)

这样做之后,一切正常。(先前答案中使用的线索:https: //github.com/spring-projects/spring-loaded/issues/98

回答by Neoecos

From https://github.com/spring-projects/spring-loaded/issues/98and worked to me

来自https://github.com/spring-projects/spring-loaded/issues/98并为我工作

wget repo.spring.io/libs-snapshot-local/org/springframework/springloaded/1.2.3.BUILD-SNAPSHOT/springloaded-1.2.3.BUILD-SNAPSHOT.jar -O ~/.gvm/grails/2.4.4/lib/org.springframework/springloaded/jars/springloaded-1.2.1.RELEASE.jar

wget repo.spring.io/libs-snapshot-local/org/springframework/springloaded/1.2.3.BUILD-SNAPSHOT/springloaded-1.2.3.BUILD-SNAPSHOT.jar -O ~/.gvm/grails/2.4.4/lib/org.springframework/springloaded/jars/springloaded-1.2.1.RELEASE.jar

回答by Hussain Akhtar Wahid 'Ghouri'

Step 1 : Download this jar

第 1 步:下载这个jar

step 2 : put it into the grails folder: grails-2.4.1/lib/org.springframework/springloaded/jars

第 2 步:将其放入 grails 文件夹:grails-2.4.1/lib/org.springframework/springloaded/jars

should be enough , restart IDE

应该够了,重启IDE

回答by V H

I thought I should add my two pence worth on this topic. Recently I hit the same issue trying to upgrade an ancient app to 2.4.4. The reason for my post is because all of the above instructions are a little out of date and whilst in most cases it may appear to work. The moment you introduce mysql drivers all of the above mentioned versions of spring loaded hit a new issue around incompatibility and Non-root when attempting to trigger the database.

我想我应该在这个话题上加上我的两便士。最近我在尝试将一个古老的应用程序升级到 2.4.4 时遇到了同样的问题。我的帖子的原因是因为上述所有说明都有些过时,而在大多数情况下,它似乎有效。当您引入 mysql 驱动程序时,所有上述版本的 spring 加载在尝试触发数据库时遇到了关于不兼容和非 root 的新问题。

I got ggts fully working with JDK 1.8_065. To make it work get hold of springloaded-1.2.5.RELEASE.jarPut this into grails-2.4.4/lib/org.springframework/springloaded/jars/folder. When you install ggts inside the ggts-bundle folder is grails-2.4.4. So put the file in the above location within the ggts-bundle folder. Unless you have changed configuration.
Re-launch GGTS I spent ages on it and thought I should update the instructions.

我让 ggts 与 JDK 1.8_065 完全兼容。为了让它工作得到springloaded-1.2.5.RELEASE.jar把它放到grails-2.4.4/lib/org.springframework/springloaded/jars/文件夹中。当你在 ggts-bundle 文件夹中安装 ggts 是 grails-2.4.4。因此,将文件放在 ggts-bundle 文件夹中的上述位置。除非您更改了配置。
重新启动 GGTS 我花了很长时间,并认为我应该更新说明。

Also the other thing that I hit issues around was forking under grails 2.4.4 with my uprade and ended up setting

我遇到的另一件事是在 grails 2.4.4 下用我的升级分叉并最终设置

grails.project.fork = []

In my BuildConfig.groovy

在我的 BuildConfig.groovy

回答by vineet sagar

Two Step To Make it Work

两步让它发挥作用

1. Download JDK Lower Version:Install jdk1.8.0_25 from link http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html#jdk-8u25-oth-JPR. It's the lower version of JDK as grails dont support higher version. Maybe They'll include this in latest version soon.

1.下载JDK低版本:http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html#jdk-8u25-oth-JPR链接安装jdk1.8.0_25 。这是 JDK 的低版本,因为 grails 不支持高版本。也许他们很快就会在最新版本中包含这个。

2. Set Up Environment Variables:Don't forget to change the Enviromental variables for jdk, you have to just edit Path Variables and JavaHome Variable from "C:\Program Files\Java\jdk1.8.0_'LatestVersion'" to "C:\Program Files\Java\jdk1.8.0_25".

2.设置环境变量:不要忘记更改jdk的环境变量,您只需将Path Variables和JavaHome Variable从“C:\Program Files\Java\jdk1.8.0_'LatestVersion'”编辑为“C :\Program Files\Java\jdk1.8.0_25"

回答by Lalith Kiran R Mannur

Changing the springloaded version in my pom.xml did the trick.

在我的 pom.xml 中更改 springloaded 版本可以解决问题。

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>springloaded</artifactId>
    <version>1.2.6.RELEASE</version>
</dependency>

When I was experiencing the issue my springloaded version was 1.2.1.RELEASE

当我遇到这个问题时,我的 springloaded 版本是 1.2.1.RELEASE