Deployment of External WAR files in SAP Hybris
(I published this article on March 15, 2019 in Linkedin)
In this short article i will explain how to deploy external war files in Hybris(we did that when we integrated web chat to Hybris store).
First, let me explain the concept of localextension.xml and extensioninfo.xml.
extensioninfo.xml.
Extensions in Hybris are like projects in Java. Each extension has functionality, it’s own data model, spring configurations, properties and etc. Each extension should have a file called extensioninfo.xml where we can find all the information about the extension like extension name, extension module(Core, Web or HMC) and dependencies on other extension.
Example:
<extensioninfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="extensioninfo.xsd"> <extension abstractclassprefix="Generated" classprefix="<CUSTOM>Facades" name="<CUSTOM>facades"> <!-- you should add all required extensions to this list, except platform
extensions which are automatically required -->
<requires-extension name="acceleratorfacades" />
<requires-extension name="<CUSTOM>ore" />
<requires-extension name="<CUSTOM>crmintegration" />
<requires-extension name="<CUSTOM>erpintegration" />
<requires-extension name="sapordermgmtb2bfacades" />
<requires-extension name="commercefacades" /> <coremodule generated="true" manager="de.hybris.platform.jalo.extension.GenericManager"
packageroot="com.<CUSTOM>.facades" /> </extension></extensioninfo>
localextension.xml
Each active extension of our Hybris project must find place in localextension.xml. It contains all of extensions which our configuration include in compile- and run-time.
Example:
<hybrisconfig xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:noNamespaceSchemaLocation='../bin/platform/resources/schemas/extensions.xsd'>
<extensions>
<extension name='mcc' />
<extension name='commercesearchbackoffice' />
<extension name='b2bcommercebackoffice' /> <extension name='couponbackoffice' />
<extension name='droolsruleengineservices' />
<extension name='couponfacades' />
<extension name='promotionenginesamplesaddon' />
<extension name='accountsummaryaddon' />
<extension name='secureportaladdon' />
<extensions>
</hybrisconfig>
Deployment of External war files
To deploy external war files we need to add webapp element to localextensions.xml.
External web applications are extracted and copied to the <HYBRIS_BIN_DIR>/bin/custom directory.
The webapp element can have either one (context) or two (contextroot, path) attributes.
Example with contextroot
contextroot — is the webroot for web application
path — is the path to the war file or the exploaded webapp directory
<extensions>
<extension .../>
<webapp contextroot="webchat" path="${HYBRIS_CONFIG_DIR}/path/webchat.war"/> </extensions>
Example with context
context — is the path to context.xml which describes webapp
<extensions>
<extension .../><webapp context="/path/context.xml" /> </extensions> </extensions>
Example context.xml:
<Context path="/webchat" docBase="/path/webchat.war" />
Make sure you give this post a clap and follow my blog if you find it helpful.