Ofbiz hot-deploy / cache conflict

335 views Asked by At

I'm developing a new component in the ofbiz's hot-deploy folder.

Regarding the workflow, when new modifications are made in .java classes, I run the component's ant build command from a different terminal.

After the rebuilt is complete, the log informs me that the Controller has remounted my component. However, the changes made do not reflect in the application .

However, there is one case when the classes are correctly reloaded and the application behavior complies the modifications. If the class was never loaded by the ClassLoader (It was never accessed) the modifications are visible. This led me to think that the classes / jar are cached somewhere in the application and the new changes are not taken in consideration (thus completely defeating the idea of hot-deploy in the first place).

Is this the actual problem or am I missing something else. Is there a way to disable this caching?

1

There are 1 answers

0
David E. Jones On

OFBiz does use a caching class loader, which is probably what you're running into (see CachedClassLoader.java). However, depending on how you are running OFBiz there may be other issues with the underlying class loader.

The hot-deploy directory in OFBiz is not a true hot deploy, it is more of an automatic deploy for component directories in it. In general with OFBiz most resources are more script-like and it is generally better to write code in Groovy or simple-method scripts, and then they will update automatically (with the default cache settings, with production cache settings they require a manual cache clear in the webtools webapp).

Depending on how you deploy OFBiz reloading certain compiled classes won't work in general because they are shared between webapps so you're looking at reloading classpath resources that are outside a webapp. This is very different from the idea of hot deploy simple webapps or WAR files with an isolated class loader.