How to Integrate DCEVM code hot-swapping with Hybris Platform

Are you tired of restarting Hybris Platform everytime you change some Java code? Don’t worry, it happens to everyone. The good news is, there are tools available in the market which allow hot-swapping Java code in runtime(No need to redeploy). Like Jrebeldcevm etc.
Well, Jrebel is very good tools, having many features, but everyone can't afford it(Not free!!). If you are an open sourcist (like me), go with open source DCEVM (Dynamic Code Evolution VM).

Continue reading this post if you are looking for
How to integrate DCEVM with Hybris Platform?
JRebel alternatives for SAP Hybris
Java code hot-swapping in Hybris

Although, this is documented in help.hybris, here I'm elaborating exact steps/commands, which I've followed to configure DCEVM in my windows system.

1. Download DCEVM

Download the latest release of DCEVM jar.
enter image description here

There are two modes to install the DCEVM
Enhanced Debugger (I'm going to configure this here)
This is the simplest mode where the patched JVM allows to use the debug mode in the normal way and also to redeploy almost any class change. This mode requires only the DCEVM JVM patch, there is no other configuration needed.
JRebel Mode
This is essentially how JRebel works. You are not limited to redeploying the current class that you debug. Any class can be modified and redeployed by compiling the code. This requires the DCEVM patch and the Java Agent.

2. Install DCEVM
To install DECEVM, open CMD as administrator.
Click on Start > search cmd > right click > run as administrator
Run the below command. Make sure to change jar path with yours.
java -jar "D:\Software\HotSwap DCEVM-8u172-installer.jar"
This will open a new window to initiate software installation. Select JDK and click on "Install DCEVM as altjvm" button. If there is any error, try a different older version.
enter image description here


 - Make sure you have setup JAVA_HOME with above JDK path in your system

3. Configure the properties file


Add the following configuration to your local.properties file.

Set your Garbage Collector to be Serial GC (remove any other conflicting garbage collector definitions)

tomcat.generaloptions=-XX:+UseSerialGC...

Configure the DCEVM as an alternative engine
tomcat.debugjavaoptions=-XXaltjvm=dcevm -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n

4. Deploy the configuration

Run ant command from the platform directory to deploy tomcat changes.

5. Start the server

Start the server in debug mode.
hybrisserver.bat debug

6. Configure a remote server in IDE

Configure the remote server to debug Hybris application in your IDE. Now put the breakpoint and do your changes in java file. Which will be reflected without restarting the server if HotSwap will be triggered. Otherwise, you can simply do ant build (not ant all) in the new console. Which will generate .class file with your changes(verify it). Now you can continue your testing...

Code hot-swapping is really hot, isn't it??
Author Image

Ankitkumar Patel

Sr. SAP Hybris consultant, having 15+ years experience in SAP Commerce Cloud (Hybris), SAP Spartacus. Extensive experience in SAP Hybris development, third-party integrations, project architecture and design... Read more

Comments

  1. Can you elaborate on step 6 : "Configure the remote server to debug Hybris application in your IDE"

    ReplyDelete
    Replies
    1. Refer:
      https://www.helphybris.com/2018/03/how-to-debug-hybris-application.html

      To know how to configure debug hybris application

      Delete
  2. I am getting below error

    Launching a JVM...
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.
    Must use the serial GC in the DCEVM
    JVM exited while loading the application.
    Reloading Wrapper configuration...

    ReplyDelete
  3. I'm running Hybris 1905 now, this works with Java 11, I can't see a DCEVM jar for Java 11, is there a way to configure it?

    ReplyDelete

Post a Comment

Popular posts from this blog

Hybris flexible search query examples

How to remove or update all data records in Hybris?

How to Install temporary Hybris license?