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

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

Closed
kdvolder opened this issue Sep 5, 2018 · 9 comments
Assignees
Milestone

Comments

@kdvolder
Copy link

kdvolder commented Sep 5, 2018

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
@fbricon
Copy link
Collaborator

fbricon commented Sep 5, 2018

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

@andxu
Copy link
Contributor

andxu commented Sep 5, 2018

@fabferri @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>

@kdvolder
Copy link
Author

kdvolder commented Sep 5, 2018

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).

@andxu
Copy link
Contributor

andxu commented Sep 5, 2018

@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

@andxu andxu self-assigned this Sep 5, 2018
@andxu andxu added this to the 0.13.0 milestone Sep 5, 2018
@andxu
Copy link
Contributor

andxu commented Sep 6, 2018

@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**

@testforstephen testforstephen mentioned this issue Sep 6, 2018
15 tasks
@fbricon
Copy link
Collaborator

fbricon commented Sep 6, 2018

@andxu yes, runtime dependencies are seen by the test code, in Maven. Hence the test flag

@andxu
Copy link
Contributor

andxu commented Sep 6, 2018

@fbricon, could you please take a look at my code fix?

@andxu
Copy link
Contributor

andxu commented Sep 6, 2018

microsoft/java-debug#219

@andxu
Copy link
Contributor

andxu commented Sep 6, 2018

Close the issue since hotfix is released

@andxu andxu closed this as completed Sep 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants