Tu Trinh
Tu Trinh

Reputation: 157

How to config jrebel in Hybris backoffice extensions?

After I created one backoffice extension using "ant extgen with ybackoffice template". And I want add jrebel to this backoffice extensions but not reloading when i change code. So, please help me to solve the problem to save time for deployment.Thanks

Upvotes: 1

Views: 837

Answers (1)

user8171823
user8171823

Reputation:

Check if backoffice extensions packaged as .jar packages contain rebel.xml files and if you make a code change in .java file, new .class files are generated in $PLATFORM_HOME/bin/custom/$EXTENSION_NAME/backoffice/classes directory that is defined in rebel.xml.

copy-paste from documentation portal:

Backoffice extensions that are packaged as JAR files need a descriptor file called rebel.xml. This XML file will tell JRebel that the .class files for this JAR are in that folder. To achieve this, you will need to do the following for all extensions you want reloaded:

To recompile via an IDE, set the compile output to where the classes are actually compiled to with ant build. For backoffice extensions, this would be $PLATFORM_HOME/bin/custom/$EXTENSION_NAME/backoffice/classes.

Create the following rebel.xml in $EXTENSION_NAME/backoffice/resources:

<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">
  <classpath>
    <!-- Make sure to replace $PLATFORM_HOME and $EXTENSION_NAME with your concrete values -->
    <dir name="$PLATFORM_HOME/bin/custom/$EXTENSION_NAME/backoffice/classes"/>
  </classpath>
</application>

Edit $EXTENSION_NAME/buildcallbacks.xml and add the following before build callback:

<macrodef name="$EXTENSION_NAME_before_build">
  <sequential>
    <mkdir dir="${ext.$EXTENSION_NAME.path}/backoffice/classes" />
      <copy file="${ext.$EXTENSION_NAME.path}/backoffice/resources/rebel.xml" todir="${ext.$EXTENSION_NAME.path}/backoffice/classes/" failonerror="false" />
  </sequential>
</macrodef>

This will make sure that rebel.xml is bundled into the compiled extension JAR file on build.

When changing classes from the IDE, just recompile the class (either with ant build or via the IDE after setting the correct compile output) and reload the browser. The changed .class files are picked up by JRebel and reloaded on the fly.

Upvotes: 2

Related Questions