Skip to content

Redhat.java update to version 0.30.0 broke launching/debugging of Spring boot-apps #402

Closed

Description

An simple boot app, which was running just fine before suddenly stopped launching properly right after the redhat.java extension was updated to version 0.30.0.

The error looks to me like there's something wrong (missing) from the app's runtime classpath. This cause the app to not properly boot up.

Environment
  • Operating System: Linux
  • JDK version: "1.8.0_181"
  • Visual Studio Code version: 1.26.1
    493869ee8e8a846b0855873886fc79d480d342de
    x64
  • Java extension version: 0.30.0
  • Java Debugger extension version: 0.12.1
Steps To Reproduce
  1. unzip attached project hello-world-service.zip
  2. Open visual studio code from the attached project's folder with cd hello-world-service and code ..
  3. Press F5 to launch app.
Current Result

Error:

Caused by: java.lang.IllegalStateException: Attempted to load applicationConfig: [classpath:/application.yml] but snakeyaml was not found on the classpath
	at org.springframework.boot.env.YamlPropertySourceLoader.load(YamlPropertySourceLoader.java:47)
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadDocuments(ConfigFileApplicationListener.java:542)
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:515)
	... 23 common frames omitted
Expected Result

App starts succesfully. E.g. you can compare to what supposed to happen by running the app from commandline:

./mvnw clean package
java -jar target/*.jar

Activity

  1. fbricon commented on Sep 5, 2018

    @fbricon
    Collaborator

    most likely this is caused by runtime dependencies now being flagged to be seen by the test dependencies only. The debugger should ensure runtime dependencies are added to the runtime classpath

  2. andxu commented on Sep 5, 2018

    @andxu
    Contributor

    Fabrizio Ferri (@fabferri) Kris De Volder (@kdvolder) looks like my change of removing test scope classpath, see #399 microsoft/java-debug#202, please add snakeyaml first if it blocks you, I am looking for the reasons.

    <dependency>
    			<groupId>org.yaml</groupId>
    			<artifactId>snakeyaml</artifactId>
    			<version>1.16</version>
    		</dependency>
    
  3. kdvolder commented on Sep 5, 2018

    @kdvolder
    Author

    Removing test scope classpath actually sounds like the right thing to do. Having test dependencies on the runtime classpath can also break apps (especially in spring boot where autoconfiguration can easily pick up on the presence of certain things on the classpath and autmatically configure them for use in the app.

    However, I suspect that maybe the classpath that vscode-java-debug is using is actually the classpath meant to be used by Java compiler. So it is actually a compile-time classpath, not the classpath that should be used to launch an app. The compile time classpath is different (typically smaller than) the runtime classpath.

    The fact that test dependencies where there before was wrong i.m.o, and that it actually made my simple app run is more of an 'accident'. (Two wrongs kind of making things work, because one mistake compensated and fixed the problem caused by another... completely by luck/chance).

  4. andxu commented on Sep 5, 2018

    @andxu
    Contributor

    Kris De Volder (@kdvolder) seems we has missed some run-time scope class-entries, thank you very much for noticing us:

    maven.pomderived=true
    test=true
    maven.groupId=org.yaml
    maven.artifactId=snakeyaml
    maven.version=1.19
    maven.scope=runtime

    image

  5. added this to the 0.13.0 milestone on Sep 5, 2018
  6. andxu commented on Sep 6, 2018

    @andxu
    Contributor

    Fred Bricon (@fbricon) not sure whether the following logic is right, the isOnlyVisibleByTests will mark runtime scopes test, is it expected?
    https://git.eclipse.org/c/m2e/m2e-core.git/tree/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/DefaultClasspathManagerDelegate.java#n166

      private boolean isOnlyVisibleByTests(Artifact a) {
        return Artifact.SCOPE_TEST.equals(a.getScope()) || Artifact.SCOPE_RUNTIME.equals(a.getScope());
      }
    
    [INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:2.0.0.RELEASE:compile
    [INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.0.0.RELEASE:compile
    [INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.0.RELEASE:compile
    [INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
    [INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
    [INFO] |  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
    [INFO] |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
    [INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
    [INFO] |  |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
    [INFO] |  |  \- **org.yaml:snakeyaml:jar:1.19:runtime**
    
  7. fbricon commented on Sep 6, 2018

    @fbricon
    Collaborator

    Andy Xu(devdiv) (@andxu) yes, runtime dependencies are seen by the test code, in Maven. Hence the test flag

  8. andxu commented on Sep 6, 2018

    @andxu
    Contributor

    Fred Bricon (@fbricon), could you please take a look at my code fix?

  9. andxu commented on Sep 6, 2018

    @andxu
    Contributor
  10. andxu commented on Sep 6, 2018

    @andxu
    Contributor

    Close the issue since hotfix is released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions