40

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

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$3$1.run(CachedClass.java:84)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.codehaus.groovy.reflection.CachedClass$3.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.

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"

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).

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.

My Eclipse installation information lists the following under 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
eclipse.p2.data.area=@config.dir/../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
Al-Punk
  • 3,531
  • 6
  • 38
  • 56
  • 1
    Looks like you are hitting a change in Java 1.8 update 40 which no longer allows what this code is trying to do – greg-449 Mar 05 '15 at 15:19
  • 1
    I dislike any solutions that require downgrading Java updates. The updates are there for a reason (sometimes security related) and taking steps backward should be avoided, especially for production. There is a solution below that does not require downgrading the Java version. – dustmachine Mar 30 '15 at 18:58

10 Answers10

23

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

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)

If you want to rollback instead

Grails is natively supported in 1.8.0_25, 1.8.0_31

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.

set JAVA_HOME=C:\java\jdk1.8.0_25
set PATH=%JAVA_HOME%\bin;%PATH%;
penguin
  • 724
  • 5
  • 11
21

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.

Fernando
  • 250
  • 1
  • 2
19

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)

  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 jars subdir: 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)

dustmachine
  • 10,622
  • 5
  • 26
  • 28
  • GGTS has a bundled version of Grails. Repeat the solution in another directory like `/Applications/ggts-bundle//grails-2.4.4/lib/org.springframework/springloaded/jars/` – dustmachine Mar 30 '15 at 19:00
  • 2
    i confirm also : springloaded-1.2.5 – Abdennour TOUMI Nov 03 '15 at 18:05
  • 5
    it works. But don't forget to: a. rename the new JAR to the old JAR's file name (for example: springloaded-1.2.1.RELEASE.jar) b. clean your project – Arye Rosenstein Jan 27 '16 at 00:04
  • pls don't rename jars to different version numbers. there must be a better way. – dustmachine Jun 14 '16 at 03:31
  • 1
    This is the best answer as it 1) doesn't recommend downgrading your Java version and 2) includes a link to the live repo with the latest builds (the 1.2.2 build linked to in penguin's answer does not work with Java version 1.8.0_92). However it should mention that the new JAR needs to be renamed to match the old JAR's version number. – aroth Aug 25 '16 at 13:48
11

Step 1 : Download this jar

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

should be enough , restart IDE

6

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

guanche
  • 61
  • 4
4

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

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)
TriumphST
  • 1,194
  • 1
  • 10
  • 17
2

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

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

Neoecos
  • 569
  • 4
  • 16
1

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.

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" .

Hank
  • 231
  • 5
  • 13
1

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

<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

0

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.

I got ggts fully working with JDK 1.8_065. To make it work get hold of springloaded-1.2.5.RELEASE.jar Put 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.

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

grails.project.fork = []

In my BuildConfig.groovy

V H
  • 8,382
  • 2
  • 28
  • 48