Has anyone had success with Grails 4 / Java 11 and using DCEVM for hotswapping during development?

787 views Asked by At

We upgraded to Grails 4 / Java 11 and lost hot-swapping capabilities during development. I tried DCEVM but the application wouldn't start (errors on first withNewSession call).

Has anyone had success with getting Grails and DCEVM to work together?

2

There are 2 answers

0
Madanji Choudhary On

Recently I tried with Hybris2005 + Java 11 + Windows + Eclipse.

Follow below given steps and do modification as per your need.

DCEVM 11 Configuration Step.

  1. Download and extract java11-openjdk-dcevm-windows.zip in your local machine
  2. Set JAVA_HOME=D:\java11-openjdk\dcevm-11.0.10+3 (Adjust the path as per location in your system)
  3. In eclipse go to windows->Preference->Installed JRE and set JRE home to D:\java11-openjdk\dcevm-11.0.10+3 4 In local.properties adjust the property tomcat.debugjavaoptions as below

tomcat.debugjavaoptions=-XX:HotswapAgent=core -javaagent:D:/java11-openjdk/dcevm-11.0.10+3/lib/hotswap/hotswap-agent.jar=disablePlugin=Log4j2,disablePlugin=Spring,disablePlugin=Proxy,disablePlugin=AnonymousClassPatch,disablePlugin=ZK,autoHotswap=true -Djava.locale.providers=COMPAT,CLDR -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n -Xmx4G -Xms2G

  1. Also, please set ANT_HOME environemnt variable so that we don't to run setantenv.bat from \hybris\bin\platform and update the PATH variable accordingly.

  2. Perform ant clean all and start hybris in debug mode.

  3. Add System.out.println() statement in your code and then execute ant build command from that specific extension folder.

  4. Verify if HOT swap is done.

4
Dewi Roberts On

I've got hotswap working with Grails 5.1.2 but the Hibernate plugin causes a

org.hibernate.HibernateException: No Session found for current thread

so I had to disable the plugin. This means any changes to domain classes will still need a restart.

You'll need a copy of groovyReset.jar to avoid random errors due to Groovy caching methods that have been replaced by hotswap.

  1. sdk install java 11.0.9-trava

  2. sdk use java 11.0.9-trava

  3. Add a copy of groovyReset.jar to your project root

  4. Add the following to the bootRun jvmArgs in build.gradle:

    '-XX:HotswapAgent=fatjar',

    '-javaagent:groovyReset.jar'

  5. Create src/main/resources/hotswap-agent.properties containing:

    disabledPlugins=Hibernate

    autoHotswap=true

  6. You should now be able to start Grails and any code changes will be picked up without restarting.