JRebel not listening or reloading changes in src/main/resources directory
Asked Answered
S

8

5

JRebel not listening or reloading changes in src/main/resources directory making reading such files return cached and invalid value.

Is this normal?

Stepparent answered 30/8, 2014 at 15:20 Comment(0)
B
1

I've had the same issue, and reading the manual i found a solution that works for me.

I'm using a JSF project with Spring 3, with netbeans and running jrebel via IDE

Notice that the comments were things that i have tried previously, it doesn't means that won't work.

The important thing here is the addition of resource path into classpath and the elimination of the link tag that jrebel puts automatically into the web node.

rebel.xml:

<application generated-by="netbeans"
    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="/path_to_project_root/target/classes"></dir>-->
    <dirset dir="/path_to_project_root/">
        <include name="**/target/classes"/>
        <include name="**/src/main/resources"/>
    </dirset> 
    </classpath>

    <web>
    <!--<link target="/">-->
        <dir name="/path_to_project_root/src/main/webapp"></dir> 
        <dir name="/path_to_project_root/src/main/resources"></dir> 
    <!--</link>-->
    </web>

</application>

Also i configured the plugin in the pom.xml, setting the property addResourcesDirToRebelXml to true

pom.xml:

<plugin>
    <groupId>org.zeroturnaround</groupId>
    <artifactId>jrebel-maven-plugin</artifactId>
    <version>1.1.7</version>
    <configuration>
        <addResourcesDirToRebelXml>true</addResourcesDirToRebelXml>
    </configuration>
    <executions>
        <execution>
            <id>generate-rebel-xml</id>
            <phase>process-resources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>               
</plugin> 

source: https://manuals.zeroturnaround.com/jrebel/standalone/advanced-config.html

Brasca answered 8/9, 2017 at 8:25 Comment(1)
You can also use relative paths target/classes instead of /path_to_project_root/target/classesBrasca
U
6

Make sure that the directory is listed in rebel.xml configuration file that is deployed with the app. If your rebel.xml was generated with JRebel plugin for Maven, then just make sure you specify that you want the resources directory to be included into the configuration:

<addResourcesDirToRebelXml>true</addResourcesDirToRebelXml>  

If you're using IntelliJ IDEA, and you don't see the changes applied to the resources, then you probably haven't configured the IDE to copy the files from resources directory to the target directory. Or mark the resources directory as "resources" directory (Right click on the folder in the project tree -> Mark directory as...)

Unconscionable answered 31/8, 2014 at 18:38 Comment(5)
The directory is marked as a resource directory in Intellij, however I am unsure if it is being copied to the target directory. How can I do that? How do I define it in the jrebel config?Stepparent
In IntelliJ IDEA, if the directory is marked as a Resources Root, then all its contents will be automatically copied to the compiler target directory. So you can check, if you make a change to any of the resources, is the file updated in the target folder. Or, if that doesn't see to work, you can just add that folder into rebel.xml configuration file, so that JRebel could monitor that resources directory.Unconscionable
In rebel.xml, is it this that should be added: <classpath> <dir name="/path/to/app/src/main/resources/"> </dir> </classpath>Stepparent
This is not working. I've spent the entire day trying to get this to work. I have to move things into the webapp folder to get the resources to reload. Putting them into the src/main/resources folder does not reload anything.Stepparent
The best for you would be to reproduce it with logging enabled and send the jrebel.log file to JRebel support. Might it be that your configuration file is just overwritten with an automatically generated file? Maybe you use JRebel maven plugin and it generates new configuration without the resource directory in it. On startup, JRebel prints the list of directories that it monitors.Unconscionable
R
1

In case you are using IntelliJ IDEA try "Make Project" under "Build" tab or by pressing Ctrl+F9.

Renin answered 29/10, 2014 at 15:40 Comment(1)
For this to work, the compiler configuration have to be set to copy the resources to the target folder, which is now irrelevant since in IDEA 13 a notion of "resource" folders was introduced and all the resources are copied automatically.Unconscionable
B
1

I've had the same issue, and reading the manual i found a solution that works for me.

I'm using a JSF project with Spring 3, with netbeans and running jrebel via IDE

Notice that the comments were things that i have tried previously, it doesn't means that won't work.

The important thing here is the addition of resource path into classpath and the elimination of the link tag that jrebel puts automatically into the web node.

rebel.xml:

<application generated-by="netbeans"
    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="/path_to_project_root/target/classes"></dir>-->
    <dirset dir="/path_to_project_root/">
        <include name="**/target/classes"/>
        <include name="**/src/main/resources"/>
    </dirset> 
    </classpath>

    <web>
    <!--<link target="/">-->
        <dir name="/path_to_project_root/src/main/webapp"></dir> 
        <dir name="/path_to_project_root/src/main/resources"></dir> 
    <!--</link>-->
    </web>

</application>

Also i configured the plugin in the pom.xml, setting the property addResourcesDirToRebelXml to true

pom.xml:

<plugin>
    <groupId>org.zeroturnaround</groupId>
    <artifactId>jrebel-maven-plugin</artifactId>
    <version>1.1.7</version>
    <configuration>
        <addResourcesDirToRebelXml>true</addResourcesDirToRebelXml>
    </configuration>
    <executions>
        <execution>
            <id>generate-rebel-xml</id>
            <phase>process-resources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>               
</plugin> 

source: https://manuals.zeroturnaround.com/jrebel/standalone/advanced-config.html

Brasca answered 8/9, 2017 at 8:25 Comment(1)
You can also use relative paths target/classes instead of /path_to_project_root/target/classesBrasca
A
1

Make sure your project doesn´t have any compilation error in eclipse.

Also check your JDK Compliance. I had the wrong version and my target/classes files were not updated.

If the target/classes content is not updated, jrebel won´t see any changes.

Arrivederci answered 11/12, 2017 at 9:3 Comment(0)
L
1

Simply, add root path to rebel.xml inside classpath as named dir with exactly path. For example My project have classes and also resource files under java dir, so I setted as:

<?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_3.xsd">

    <id>$your project id$</id>

    <classpath>
        <dir name="$yourProjectPath$/out/production/resources">
        </dir>
        <dir name="$yourProjectPath$/src/java/">
        </dir>
        <dir name="$yourProjectPath$/out/production/classes">
        </dir>
    </classpath>

</application>
Lashaun answered 10/10, 2022 at 11:41 Comment(0)
O
0

I have used something like that and it worked for me. JRebel plugin needs to be installed on IDEA or you can use plugin in pom.xml

Note 1: rebel.xml file was automatically generated by JRebel plugin on IDEA into src/main/resources, so that there is not needed jrebel plugin to be added into pom.xml

Note 2: Don't forget to keep slash in the path, not backslash! ;)

<?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://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">

  <classpath>
    <dir name="C:/myWorkspace/myWar/target/classes"></dir>
  </classpath>

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

</application>
Otisotitis answered 12/10, 2020 at 14:41 Comment(0)
D
0

If you use IDEA ,you can set like this:

Diastyle answered 1/8, 2023 at 2:6 Comment(0)
R
0

Another option is to refer to target/generated-webapp with following config in jrebel.xml

     <web>
        <link target="/">
            <dir name="/path_to_project_root/target/generated-webapp/resources">
                <exclude name="/"/>
            </dir>
        </link>
        <link target="/">
            <dir name="/path_to_project_root/src/main/webapp">
            </dir>
        </link>
    </web>

add maven resources plugin

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-resources</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}/generated-webapp/resources</outputDirectory>
                <resources>
                    <resource>
                        <directory>${project.basedir}/src/main/webapp/resources</directory>
                        <includes>
                            <include>**/*.css</include>
                            <include>**/*.js</include>
                        </includes>
                        <excludes>
                            <exclude></exclude>
                        </excludes>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>
Reproachful answered 27/9, 2023 at 13:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.