0

I have a modular web project and thus I am allowing modules to be a war archive including webapp folder. Using the following rebel.xml works fine on detecting class changes over all modules. But for some reason jrebel does not move when a html or js is changed.

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com"
             xsi:schemaLocation="http://www.zeroturnaround.com http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd">

    <classpath>
        <!-- appserver -->
        <dir name="/home/xx/data/appserver/target/classes/main"/>
        <dir name="/home/xx/data/appserver/target/resources/main"/>

        <!-- module -->
        <dir name="/home/xx/data/as.module.core/target/classes/main"/>
        <dir name="/home/xx/data/as.module.core/target/resources/main"/>

        <dir name="/home/xx/data/as.module.mqlcore/target/classes/main"/>
        <dir name="/home/xx/data/as.module.mqlcore/target/resources/main"/>
    </classpath>

    <!-- web>
        <link target="/">
            <dir name="/home/xx/data/appserver/src/main/webapp"/>
            <dir name="/home/xx/data/as.module.core/src/main/webapp"/>
            <dir name="/home/xx/data/as.module.mqlcore/src/main/webapp"/>
        </link>
    </web -->

    <web>
        <link target="/">
            <dirset dir="/home/xx/data">
                <include name="**/src/main/webapp"/>
            </dirset>
        </link>
    </web>
</application>

EDIT:

Interesting fact is. When I use the commented part of web configuration all three webapp folders are in the log and will be monitored for changes. But the application server can not find all of the webapp files. When I use the second <web> configuration all files are seen by the application server but are not observed by jrebel. I think it is not possible to have multiple directories linked to "/"

KIC
  • 5,887
  • 7
  • 58
  • 98

2 Answers2

0

Each of the modules eg .war or .jar files need to have their own rebel.xml files. Otherwise all of them will reload same resources and when having different classloaders all kind of weird things can happen.

It is possible to check which instance of the file JRebel actually uses by searching "found resource" from jrebel.log. It should be written something like this sun.misc.Launcher$AppClassLoader@184be29 found resource: 'cfg/log4j.xml' from 'file:/C:/Projects/testproject/Trunk/edm/target/cfg/log4j.xml'.

It is also seen which of the file changed by loking up lines with Event like this: [IntelliJFSNotify] Event 'CHANGE' on: 'C:/Projects/testproject/Trunk/edm/target/cfg/log4j.xml'

Usually found resource and changed file paths do not match if the file is not reloaded. If they do match then it is recommended to send absolute path of the file and jrebel.log to support@zeroturnaround.com for investigation.

Margus Pala
  • 8,433
  • 8
  • 42
  • 52
  • Actually having one joint rebel.xml in the classpath of the webapp is a valid scenario. Since all module classes (not jars) are deployed into the same war (and exploded war folder structure), there is no need for additional rebel.xmls. The would simple overwrite each other. Interesingly in the log I can find JRebel: Reloading class 'xxx'. but simply nothing when changing a html file. Maybe I can tweak teh loglevel of jrebel – KIC Mar 05 '15 at 15:07
  • When starting the webserver there are several: `JRebel: Directory '.../resources/main' will be monitored for changes`. But the listed directories are all classes and resources but not "webaps" specified with in rebel.xml – KIC Mar 05 '15 at 15:25
  • @Margus, i have generated a web.xml for all my modules, and they exists in the jar file, but jrebel is only loading the single one in the web war. I don't know why. – mjs Mar 31 '20 at 12:41
0

Ok, the answer is: indeed it is not possible to configure more than one directory under the <web><link target="/"></link></web> configuration. I have now a folder ./target/all-webapp where I smylink (cp -sR) all files via gradle task ... not nice but works ... and thank god jrebel is following symlinks!

KIC
  • 5,887
  • 7
  • 58
  • 98
  • It is great that the workaround is working. However the scenario where one module has multiple source directories is supported by JRebel. Why it did not work in your case can be investigated if you try to change the file and its absolute path to JRebel support. – Margus Pala Mar 06 '15 at 08:38