Search code examples
intellij-ideamaven-3wildflyjrebelswagger-codegen

Swagger generated code keeps being deleted and re-uploaded by JRebel - endlessly


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.

Solution

  • 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 [email protected], they'll be able to provide you with more details.