0

I'm working on a Spring Multi Module Project. One of the projects contains some JSON file in a folder called drivers, located in: <Project>/src/main/resources.

When I first launch the app all the JSON files are correctly loaded, but if I make a change to one of them JRebel keeps on using the old one.

Is there a way to configure it to solve this issue?

Thank you.

Here is the rebel.xml for this project:

 <?xml version="1.0" encoding="UTF-8"?>

<application generated-by="intellij" 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>
        <dir name="C:/PathToProject/target/classes">
        </dir>
        <dir name="C:/PathToProject/src/main/resources/drivers">
        </dir>
    </classpath>

    <web>
        <link target="/">
            <dir name="C:/PathToProject/src/main/webapp">
            </dir>
        </link>
    </web>

</application>
lch
  • 2,028
  • 2
  • 25
  • 46

1 Answers1

0

Change the classpath part to

<classpath>
    <dir name="C:/PathToProject/src/main/resources/"/>
    <dir name="C:/PathToProject/target/classes"/>
</classpath>

If the application is trying to load a classpath resource, its full name is important(e.g. drivers/myfile.json) as this is what is passed to the classloader. The rebel.xml must specify paths that are classpath roots, not subfolders. For finer control you can use includes/excludes for the dir entry. Also the paths are checked in order and if it exists in the first one, that is returned even if it's older.

So in your current configuration JRebel would first search for C:/PathToProject/target/classes/drivers/myfile.json and find the old version there from the last run of maven-resources-plugin copy-resources goal or project build in IDE.

Now if only the order was fixed, the second path is still incorrect as it would look for C:/PathToProject/src/main/resources/drivers/drivers/myfile.json where it doesn't exist.

Murka
  • 353
  • 4
  • 10
  • Thank you for your answer. However I stil can't get it to load the changed file. Something else I'm missing? – lch Apr 05 '19 at 13:51
  • Depends on whether the file is being re-read after the change and whether something is caching the result. How exactly is the json file used? Does the application read it every time or only on startup and computes some data based on it? Also you can send a support ticket via IntelliJ Help -> JRebel -> Submit a Support Ticket and include the jrebel.log. They can look over it and help you out. – Murka Apr 05 '19 at 14:20
  • The file gets read every time I make a certain post request. Then I should able to edit some fields, make another post, and have the application read the same file with the edits I made. – lch Apr 05 '19 at 14:25
  • You can check the jrebel.log(default %USERPROFILE%/.jrebel/jrebel.log) which should have lines like `[some classloader] found resource: 'drivers/myfile.json' from 'file://C:/PathToProject/src/main/resources/drivers/myfile.json'.` every time the file is accessed. See if it does indeed appear every time and whether the `from` part points to `src/main/resources` or somewhere else. – Murka Apr 05 '19 at 16:47