Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotReloadCapable:true doesn't work with java-springboot #6657

Closed
Tracked by #6697
kadel opened this issue Mar 13, 2023 · 8 comments · May be fixed by odo-devfiles/springboot-ex#4
Closed
Tracked by #6697

hotReloadCapable:true doesn't work with java-springboot #6657

kadel opened this issue Mar 13, 2023 · 8 comments · May be fixed by odo-devfiles/springboot-ex#4
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/High Important issue; should be worked on before any other issues (except priority/Critical issue(s)). status/blocked Denotes an issue or PR that is blocked on something (e.g., issue/PR in different repo)
Milestone

Comments

@kadel
Copy link
Member

kadel commented Mar 13, 2023

/kind bug
/priority high

  1. odo init --name java-springboot-starter --devfile java-springboot --starter springbootproject
  2. edit devfile and add hotReloadCapable: true to run exec command
  3. run odo dev
  4. edit source code
  5. odo should just sync files and application should automatically pick up changes, but this is not happening. When running locally with mvn spring-boot:run (the same command devfile uses) it works correctly.

When trying similar steps with nodejs, it works as expected.

  1. odo init --name test --devfile nodejs --starter nodejs-starter
  2. edit devfile and add hotReloadCapable: true to run exec command
  3. install nodemon to project npm install --save-dev nodemon
  4. modify package.json and use nodemon server.js as start script
  5. run odo dev
  6. edit source code
  7. right after file sync is done you can see changes in the application

Because it works in nodejs but doesn't with springboot it looks like this is specific to springboot container.

@openshift-ci openshift-ci bot added kind/bug Categorizes issue or PR as related to a bug. priority/High Important issue; should be worked on before any other issues (except priority/Critical issue(s)). labels Mar 13, 2023
@github-actions github-actions bot added the needs-triage Indicates an issue or PR lacks a `triage/*` and requires one. label Mar 13, 2023
@feloy
Copy link
Contributor

feloy commented Mar 22, 2023

After some tests, I can see that files are correctly synced to the container, which are detected, and the rebuild is executed.

tools: [INFO] Scanning for projects...
tools: [INFO] 
tools: [INFO] --------------------------< com.example:demo >--------------------------
tools: [INFO] Building demo 0.0.1-SNAPSHOT
tools: [INFO] --------------------------------[ jar ]---------------------------------
tools: [INFO] 


tools: [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ demo ---
tools: [INFO] Deleting /projects/target
tools: [INFO] 
tools: [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ demo ---
tools: [INFO] Using 'UTF-8' encoding to copy filtered resources.
tools: [INFO] Copying 1 resource
tools: [INFO] Copying 0 resource
tools: [INFO] 
tools: [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ demo ---
tools: [INFO] Changes detected - recompiling the module!
tools: [INFO] Compiling 1 source file to /projects/target/classes
tools: [INFO] 
tools: [INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ demo ---
tools: [INFO] Not copying test resources
tools: [INFO] 
tools: [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ demo ---
tools: [INFO] Not compiling test sources
tools: [INFO] 
tools: [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ demo ---
tools: [INFO] Tests are skipped.
tools: [INFO] 
tools: [INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ demo ---
tools: [INFO] Building jar: /projects/target/demo-0.0.1-SNAPSHOT.jar
tools: [INFO] 
tools: [INFO] --- spring-boot-maven-plugin:2.3.5.RELEASE:repackage (repackage) @ demo ---
tools: [INFO] Replacing main artifact with repackaged archive
tools: [INFO] ------------------------------------------------------------------------
tools: [INFO] BUILD SUCCESS
tools: [INFO] ------------------------------------------------------------------------
tools: [INFO] Total time:  1.773 s
tools: [INFO] Finished at: 2023-03-22T07:49:49Z
tools: [INFO] ------------------------------------------------------------------------

Adding this dependency to the project fixes the issue:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>

@feloy feloy self-assigned this Mar 22, 2023
@feloy feloy removed the needs-triage Indicates an issue or PR lacks a `triage/*` and requires one. label Mar 22, 2023
@rm3l rm3l added this to the v3.9.0 🚀 milestone Mar 22, 2023
@rm3l
Copy link
Member

rm3l commented Mar 28, 2023

Separate issue: make the run command hotReloadCapable in the Devfile stack

@kadel
Copy link
Member Author

kadel commented Mar 28, 2023

I've tried adding spring-boot-devtools and it doesn't help

@feloy
Copy link
Contributor

feloy commented Mar 28, 2023

I had tested only on podman (odo dev --platform podman).

I can reproduce it on podman, but not on cluster.

After some research, I can see that the difference between both platforms is that, when you mark the Run command as hotReloadCapable, the Build command is executed after sources changes in Podman, but not on the cluster.

@kadel could you please double-check that you can reproduce on Podman?

@feloy
Copy link
Contributor

feloy commented Mar 28, 2023

As I understand:

springboot reload is done in 2 stages:

  • compiling sources into classes
  • reloading classes

The first stage is done by the Build command, after the sources are synced, and the second stage is done by mvn spring-boot:run (with spring-boot-devtools) when a class changes.

On the other hand, node reload works only with the command npm start; the Build command does not need to be ran again after each source change.

@feloy
Copy link
Contributor

feloy commented Mar 28, 2023

I've created a related issue regarding running the build command when Run is hotReloadCapable: #6695

@feloy feloy added the status/blocked Denotes an issue or PR that is blocked on something (e.g., issue/PR in different repo) label Mar 29, 2023
@rm3l rm3l modified the milestones: v3.9.0 🚀, v3.10.0 🚀 Apr 5, 2023
@rm3l rm3l modified the milestones: v3.10.0 🚀, v3.11.0 🚀 May 2, 2023
@feloy
Copy link
Contributor

feloy commented May 11, 2023

After some tests, I can see that files are correctly synced to the container, which are detected, and the rebuild is executed.

tools: [INFO] Scanning for projects...
tools: [INFO] 
tools: [INFO] --------------------------< com.example:demo >--------------------------
tools: [INFO] Building demo 0.0.1-SNAPSHOT
tools: [INFO] --------------------------------[ jar ]---------------------------------
tools: [INFO] 


tools: [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ demo ---
tools: [INFO] Deleting /projects/target
tools: [INFO] 
tools: [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ demo ---
tools: [INFO] Using 'UTF-8' encoding to copy filtered resources.
tools: [INFO] Copying 1 resource
tools: [INFO] Copying 0 resource
tools: [INFO] 
tools: [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ demo ---
tools: [INFO] Changes detected - recompiling the module!
tools: [INFO] Compiling 1 source file to /projects/target/classes
tools: [INFO] 
tools: [INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ demo ---
tools: [INFO] Not copying test resources
tools: [INFO] 
tools: [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ demo ---
tools: [INFO] Not compiling test sources
tools: [INFO] 
tools: [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ demo ---
tools: [INFO] Tests are skipped.
tools: [INFO] 
tools: [INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ demo ---
tools: [INFO] Building jar: /projects/target/demo-0.0.1-SNAPSHOT.jar
tools: [INFO] 
tools: [INFO] --- spring-boot-maven-plugin:2.3.5.RELEASE:repackage (repackage) @ demo ---
tools: [INFO] Replacing main artifact with repackaged archive
tools: [INFO] ------------------------------------------------------------------------
tools: [INFO] BUILD SUCCESS
tools: [INFO] ------------------------------------------------------------------------
tools: [INFO] Total time:  1.773 s
tools: [INFO] Finished at: 2023-03-22T07:49:49Z
tools: [INFO] ------------------------------------------------------------------------

Adding this dependency to the project fixes the issue:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>

Fixed when adding this dependency with latest odo version

/close

@openshift-ci openshift-ci bot closed this as completed May 11, 2023
@openshift-ci
Copy link

openshift-ci bot commented May 11, 2023

@feloy: Closing this issue.

In response to this:

After some tests, I can see that files are correctly synced to the container, which are detected, and the rebuild is executed.

tools: [INFO] Scanning for projects...
tools: [INFO] 
tools: [INFO] --------------------------< com.example:demo >--------------------------
tools: [INFO] Building demo 0.0.1-SNAPSHOT
tools: [INFO] --------------------------------[ jar ]---------------------------------
tools: [INFO] 


tools: [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ demo ---
tools: [INFO] Deleting /projects/target
tools: [INFO] 
tools: [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ demo ---
tools: [INFO] Using 'UTF-8' encoding to copy filtered resources.
tools: [INFO] Copying 1 resource
tools: [INFO] Copying 0 resource
tools: [INFO] 
tools: [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ demo ---
tools: [INFO] Changes detected - recompiling the module!
tools: [INFO] Compiling 1 source file to /projects/target/classes
tools: [INFO] 
tools: [INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ demo ---
tools: [INFO] Not copying test resources
tools: [INFO] 
tools: [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ demo ---
tools: [INFO] Not compiling test sources
tools: [INFO] 
tools: [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ demo ---
tools: [INFO] Tests are skipped.
tools: [INFO] 
tools: [INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ demo ---
tools: [INFO] Building jar: /projects/target/demo-0.0.1-SNAPSHOT.jar
tools: [INFO] 
tools: [INFO] --- spring-boot-maven-plugin:2.3.5.RELEASE:repackage (repackage) @ demo ---
tools: [INFO] Replacing main artifact with repackaged archive
tools: [INFO] ------------------------------------------------------------------------
tools: [INFO] BUILD SUCCESS
tools: [INFO] ------------------------------------------------------------------------
tools: [INFO] Total time:  1.773 s
tools: [INFO] Finished at: 2023-03-22T07:49:49Z
tools: [INFO] ------------------------------------------------------------------------

Adding this dependency to the project fixes the issue:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>

Fixed when adding this dependency with latest odo version

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/High Important issue; should be worked on before any other issues (except priority/Critical issue(s)). status/blocked Denotes an issue or PR that is blocked on something (e.g., issue/PR in different repo)
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants