1

I have a Wildfly Rest service that I generated from Swagger jaxrs-resteasy. The project is maven from a Jetbrains IntelliJ Idea IDE and I am also running jrebel. Everything works great with the entire setup, except that all of the code from the src/gen/java path (the generated code) keeps endlessly being deleted and uploaded by JRebel. Am I missing something in the rebel.xml file to get it to stop doing this?

JRebel console continuously cycles the following messages, and I am concerned that the power use will soon be enough to charge a Tesla...

[2017-05-08 16:10:14] Synchronization took 189 ms in total.
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Connecting to server to sync project
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/RestApplication.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/model/TaxDataResponse.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/StringUtil.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/ApiOriginFilter.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/ApiResponseMessage.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/JacksonConfig.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/AuthenticateApiService.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/RFC3339DateFormat.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/model/UserDefined.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/JacksonConfig$1$1.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/model/AuthenticationRequest.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/NotFoundException.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/TaxApiService.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/model/ChargeItemType.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/JacksonConfig$1.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/ApiException.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Deleting remote resource 'io/swagger/api/JacksonConfig$1$2.class'
[2017-05-08 16:10:21] [Project RESServices, server Local Wildfly] Upload succeeded in 147 ms. Transaction took 173 ms.
[2017-05-08 16:10:21] Synchronization took 205 ms in total.
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Connecting to server to sync project
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/RestApplication.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/JacksonConfig.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/model/UserDefined.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/RFC3339DateFormat.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/model/TaxDataResponse.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/StringUtil.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/ApiOriginFilter.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/ApiResponseMessage.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/AuthenticateApiService.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/JacksonConfig$1$1.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/NotFoundException.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/model/AuthenticationRequest.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/TaxApiService.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/model/ChargeItemType.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/JacksonConfig$1.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/ApiException.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Uploading resource 'target/classes/io/swagger/api/JacksonConfig$1$2.class'
[2017-05-08 16:10:24] [Project RESServices, server Local Wildfly] Upload succeeded in 178 ms. Transaction took 197 ms.
[2017-05-08 16:10:24] Synchronization took 197 ms in total.
Inquisitor Shm
  • 1,433
  • 5
  • 17
  • 26
  • New Information: I had IntelliJ setup to automatically build. Turning this off stopped the continuous JRebel deployment and undeployment cycle. The strange thing is that the only code affected was that code outside of src/main/java (ie: /src/gen/java) so I still think it must be possible to get JRebel to behave properly even with IntelliJ automatically building. – Inquisitor Shm May 09 '17 at 14:48

1 Answers1

1

I doubt that the issue is in rebel.xml though you could first start with a very simple rebel.xml and move on from there to verify, in your case the following should be a good start:

<?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="/absolute/path/to/project/target/classes">
        </dir>
    </classpath>
</application>

Initially JRebel does one synchronization where all the old files are deleted and new ones uploaded after which JRebel starts to monitor all the file changes in local build directory (../target/classes/) and will trigger a synchronization event after detecting a timestamp change. If the file md5 hash differs from the previous, it will be uploaded.

Additionally JRebel can monitor other resource files as well (web files, property files etc..) which can be specified in rebel.xml.

It's hard to tell what is exactly happening but my guess would be that for some reason the generated files are being recompiled very often (auto-generated timestamp maybe) and JRebel detect these files' hashes changing. You can manually check the file hashes and verify if that may be the case.

If for some reason IDEA is constantly recompiling and changing the .class files you could disable JRebel automatically synchronizing after each build. In such case you have to manually synchronize with the remote server whenever needed.

Help > JRebel > Configuration > Remote Servers > "Synchronize on build"

JRebel IntelliJ remote servers configuration

For figuring out the exact reason, please add rebel.ide.log=trace to {user.home}/.jrebel/jrebel.properties, restart IDE and reproduce the issue, the log will be generated as jrebel-intellij.log. Send it to support@zeroturnaround.com, they'll be able to provide you with more details.

käyrätorvi
  • 371
  • 1
  • 9
  • The behavior stops if I set IntelliJ to not build automatically. Since the issue affects only code from outside the src/main/java (ie: from src/gen/java) I still believe that there must be a way to setup JRebel to not continously deploy, given that when intelliJ runs with automatic build on, only the code from src/gen/java is being continously redeployed and not the code from src/main/java or the code from src/test/java. – Inquisitor Shm May 09 '17 at 14:51
  • I noticed the same thing, I was working on getting the generated sources into the proper source folder so they could actually be used. I kept deleting the docs folder, and src.main.XXX and they kept being recreated whether when deleted from OS or the IDE - unchecking build automatically resolved this! Side effects noted. – JGlass Aug 02 '23 at 18:25