0

I have a IntelliJ Community Edition with Gradle 4.3.1 and com.bmuschko.tomcat plugin running. My application will be deployed currently and its working, now I want to enable JRebel for this. So that changes on my webapp folder will be hot-deployed.

At the plugin site is a description for this

Edit your Gradle startup script and add the following line to it to tell Gradle to use the JRebel agent. Please make sure to set the environment variable REBEL_HOME that points to your JRebel installation directory.

JAVA_OPTS="-javaagent:$REBEL_HOME/jrebel.jar $JAVA_OPTS"

Currenty its not clear for me where do I need to change this? Obiously JRebel is not active when I start my tomcat with the pluging.

What I did:

  • installed the jrebel plugin in intellij
  • enabled the jrebel functionality with the ide
  • manually added a rebel.xml file (as described on the plugin site) in the build/classes/main folder

Where do I need to edit the gradle start up so that jrebel is active for gradle builds?

Al Phaba
  • 6,545
  • 12
  • 51
  • 83
  • 1
    "Edit your Gradle startup script " means to add line to your "gradlew" script. Also you could try to add JRebel to your tomcat instance (https://manuals.zeroturnaround.com/jrebel/standalone/launch-from-command-line-jrebel-agent.html#tomcat-5-x-6-x-7-x-and-8-x) and add JRebel plugin to your build script (https://manuals.zeroturnaround.com/jrebel/standalone/gradle.html). In this case you'll need to build project and then deploy it on Tomcat. – y.bedrov Jan 08 '18 at 16:23

1 Answers1

2

There are two ways you can run gradle that will affect how to add the arguments, with the daemon and without.

If you run gradle tomcatRun --no-daemon the arguments for JRebel must be added via JAVA_OPTS or GRADLE_OPTS environment variables. So this means either running as GRADLE_OPTS=-agentpath:/path/to/jrebel/lib/libjrebel64.so gradle tomcatRun --no-daemon or specifying the variable in a script(gradlew if you are using it). If you run the gradle task directly from IntelliJ, you can specify environment variables there.

If you run with the daemon, the GRADLE_OPTS variable will set JVM arguments for the launcher process, not the daemon. This will mean that JRebel is included in the wrong process and your changes aren't monitored. One way to set JVM arguments for the daemon is by adding the following to your gradle.properties

org.gradle.jvmargs='-agentpath:/path/to/jrebel/lib/libjrebel64.so'

Running with the daemon will mean that the JRebel banner is not displayed so don't be alarmed as the changes will still be monitored.

Also since JRebel 7.0 the folder structure was changed and the jrebel.jar located in installation root is the new core which requires additional bootstrapping provided by the included native agents in the jrebel/lib dir. It is suggested to use the corresponding native agent for your OS/arch using the agentpath argument and not the javaagent argument as in the tomcat plugin docs.

Murka
  • 353
  • 4
  • 10
  • Ok, I got it runnning. The tomcat starts with JRebel output, but the rebel.xml seems to be wrong, there is no hot deployment when i do file changes. But I guess I need to make another topic to discuss this. Thanks for this explanation – Al Phaba Jan 08 '18 at 20:53
  • Make sure you compiled the class file, ctrl+F9 to build project. – Henri Viik Jan 09 '18 at 06:04