0

In a Hybris developement environement, we are looking for reducing the Hybris server (Tomcat) restarts after each classes modification,

Beside the known tools available (JRebel, HotswapAgent,...), we are trying to use the tomcat server's default class/webapp reloading mechanism : reloadable="true"

It's working like a charm when making some changes on classes under the extention webroot folder,

But it's not the case when the changes are made under the [Extention]/classes folder.

So the question is :

Is it possible to make hybris server (tomcat) aware of changes on [Extention]/classes folder, and reload the corresponding webapp ? knowing that hybris has its own ClassLoading mechanism !

Environment :
Hybris 5.4
Tomcat 7.0
JDK 1.8

Best regards


--------EDIT 1-------

The build tool :

We are using only the ant commands to build/clean... the project, The IDEs (eclipse, intelliJ...) are only used for editing the source code.

The folder hierarchy :

 [HybrisFolder]
          |__bin
              |__platform
              |__custom
                  |__[ExtentionFolder]
                       |__classes
                       |__web
                           |__webroot
                               |__WEB-INF
                                   |__classes

Tryed solutions (that didn't work)

Add the [ExtentionFolder]/classes folder as watched ressource in tomcat :

  • First option :

Add it as a WatchedResource in the webapp context :

<Context reloadable="true" path="[ExtentionName]" docBase="[ExtentionFolder]/web/webroot">
  <Manager pathname="" />
  <Loader platformHome="[PlatformFolder]" className="de.hybris.tomcat.HybrisWebappLoader" deployName="default" />
  <WatchedResource>[ExtentionFolder]/classes</WatchedResource>
</Context>

==> It's not working

  • Second option :

Add it as an ExtraResource in the webapp context :

<Context reloadable="true" path="[ExtentionName]" docBase="[ExtentionFolder]/web/webroot">
  <Manager pathname="" />
  <Loader platformHome="[PlatformFolder]" className="de.hybris.tomcat.HybrisWebappLoader" deployName="default" />
  <Resources className="org.apache.naming.resources.VirtualDirContext" extraResourcePaths="/WEB-INF/classes=[ExtentionFolder]/classes"/>
</Context>

==> I get a weird error, like it was a double loading of the same class (the first loading was done by the PlatformInPlaceClassLoader of Hybris, and the second loading by tomcat)

Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: 
Bean named 'myBean' must be of type [x.y.z.DefaultMyBean], but was actually of type [x.y.z.DefaultMyBean]
khayassine
  • 96
  • 1
  • 8
  • I don't have the answer for you, but I have configured Hybris with JRebel... so if you decide to go that route feel free to comment. JRebel also has a free version called MyJRebel – Chris Maggiulli Dec 26 '17 at 22:59
  • Thanks for your answer, we have already tested JRebel, and its working good in a Hybris environement, ... but our objectif is to make it work with the tomcat reloading mechanism – khayassine Dec 27 '17 at 11:48
  • Can you post your applications context.xml, tomcat's context.xml, and server.xml. While I use JRebel for the most part I have set up watched resources once or twice before and I can take a stab at it but I need more information. Also, please post your directory structure too (if you can take a screen shot that would be best so I can see where the two classes folders are and where your web.xml is. Also your hybris version and if you are the classloader working from Eclipse or not (if so there is an extra few steps I believe). If you are using a different IDE likely cant help with that – Chris Maggiulli Dec 27 '17 at 17:28
  • I just edited the main post, and added some tryed solutions – khayassine Dec 28 '17 at 10:58
  • Ok let me play around with my local hybris environment and see what I can come up with. Quick question - failed example one has a docBase attribute set. Has that always been set with that value, or was it part of the change you made for that example? Also, is anything configured in tomcat context.xml other than a single watch resource at WEB-INF/web.xml? – Chris Maggiulli Dec 28 '17 at 21:09
  • docBase has always been set to [ExtentionFolder]/web/webroot , I tried to set it to [ExtentionFolder], but failed when starting the server (as expected). In the tomcat context.xml I found this : [ExtentionFolder] – khayassine Dec 29 '17 at 09:10
  • `` is definitely the way to do this. – Christopher Schultz May 18 '18 at 12:47

0 Answers0