How to configure JRebel with dockerized SAP Commerce(Hybris) application
What Is JRebel?
JRebel is a JVM plugin that lets Java developers instantly update code (i.e. add a new feature, fix a bug, etc) and see those changes reflected in their app under development without restarting the application server.
How it works?
JRebel works by monitoring the directory that contains the class files that are produced as part of a build. It uses “Rebellion Technology” to instantly reload changes made to a class structure, making a full app redeploy unnecessary. You just save, refresh and see the changes right away.
Starting the server with the JRebel increases the startup time by about one minute, but this cost is more than compensated for by the fact that developers no longer need to restart their servers after making changes.
I will not covering how to setup Jrebel for Hybris as it is already covered in official documentation:
https://manuals.jrebel.com/jrebel/advanced/hybris.html
I will just explain what is the difference when configuring JRebel with Docker:
Steps:
You can add JRebel in your Dockerfile:
RUN wget -O jrebel.zip http://dl.zeroturnaround.com/jrebel-stable-nosetup.zip && \
unzip jrebel.zip && \
mv jrebel /opt/jrebel && \
rm jrebel.
zip
In local property change depending on debugging: local.properties( -agentpath depends on where you downloaded your Jrebel):
tomcat.debugjavaoptions=-Xverify:none -agentpath:/opt/jrebel/lib/libjrebel64.so -Drebel.remoting_plugin=true -Drebel.remoting_port=12345 -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n#tomcat.javaoptions=-agentpath:/opt/jrebel/lib/libjrebel64.so -Drebel.remoting_plugin=true
Or you can download Jrebel manually and then in local.properties add the path:
tomcat.debugjavaoptions=-Xverify:none -agentpath:/jrebel/lib/libjrebel64.so -Drebel.remoting_plugin=true -Drebel.remoting_port=12345 -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n
#tomcat.javaoptions=-agentpath:/jrebel/lib/libjrebel64.so -Drebel.remoting_plugin=true
Install JRebel plugin:
Once you have configured JRebel in Docker and container has started, you should see the following banner during Hybris:
Add a remote server to IntelliJ IDEA
Open Settings > JRebel > Remote servers.
Press + to configure a new remote server.
Test the connection by providing the Hybris server URL :
Configure modules for remote server support(Generate all the remote XML for modules).
Make sure to build the Docker image again so as to copy all the custom files to the container. Without the remote XML, the container will not update the projects.
Make a change in your file and it will reflect in the container immediately without the server restart.
Make sure you give this post a clap and follow my blog if you find it helpful.