Closed foxpluto closed 4 years ago
Hi Stefano,
thank you so much for finding this issue. I've installed VS Code myself and I think I know where the problem lies.
The VS Code Java plugin mentions that it's using bits from the Eclipse platform and the BuildShip plugin in order to have support for Gradle. The problem is that BuildShip requires workarounds to work properly with Gradle; please see the following thread for more information: https://vaadin.com/forum/thread/18241436
The workaround is thus to manually add the build\classes\java\main
folder to the classpath. However, I'm not familiar with VS Code and I do not know how to add that folder to classpath. Since you're much more familiar with VS Code, could you please try out this workaround and let me know whether it works or not?
Ok,
I read the post and this seems the real reason. I tried a quick hack but it doesn't work but I will look more deeper in that direction and I let you know.
Thank a lot for your help.
Regards, S.
Dear Mvysny,
I have tried many different strategies but without any success.
Your supposition is definitely right, I have added to the jvm startup configuration the option -verbose:class
and i the two different project:
the maven one has:
[0.288s][info][class,load] com.vaadin.starter.skeleton.ManualJetty source: file:/Users/fox/Documents/workspace/vaadin14-embedded-jetty-master/target/classes/
[1.665s][info][class,load] com.vaadin.starter.skeleton.MainView source: file:/Users/fox/Documents/workspace/vaadin14-embedded-jetty-master/target/classes/
in the Gradle one I have only:
[0.219s][info][class,load] com.vaadin.starter.skeleton.ManualJetty source: file:/Users/fox/Documents/workspace/vaadin14-embedded-jetty-gradle-master/bin/main/
unfortunately I don't have found any way to add the others .class
files to the classpath.
Regards, S.
I'm very sorry to hear that. Unfortunately I can't help you much since I'm not familiar with VS Code at all. As a workaround, could you please try downloading Intellij Community (it's free to download and use)? I know the project works properly in Intellij including debugging.
Meanwhile I propose to leave this ticket opened; perhaps some fellow programmer using VS Code can eventually sort this out and post more information here. I will then update the README file accordingly :+1:
Another thing to try could be to open a bug report for the BuildShip plugin, or upvote the existing issue if there is one already.
Yes I will try.
Don't worry I know is a VSC specific issue; anyway with Gradle I could launch the code and attach VSC to the running application so in some way I could work in some way.
I will try to open the bug you suggest me.
I really appreciated the time you spend for my problem.
Regards, S.
No problem :+1: best of luck!
I have the solution !!!! With the help of a guy from Buildship in this post he pointed me to the right direction.
If you put this snippet of code in the gradle build file:
eclipse {
classpath {
file {
whenMerged {
def src = entries.find { it.path == 'src/main/java' }
src.output = "/$eclipse.project.name/classes/main-java"
}
}
}
}
the list of included class in the class path change from:
[0.180s][info][class,load] com.vaadin.starter.skeleton.ManualJetty source: file:/Users/fox/Documents/workspace/2020-08-26-Vaadin/bin/main/
to:
[0.161s][info][class,load] com.vaadin.starter.skeleton.ManualJetty source: file:/Users/fox/Documents/workspace/2020-08-26-Vaadin/vaadin/classes/main-java/
[1.466s][info][class,load] com.vaadin.starter.skeleton.MainView source: file:/Users/fox/Documents/workspace/2020-08-26-Vaadin/vaadin/classes/main-java/
[13.689s][info][class,load] com.vaadin.starter.skeleton.GreetService source: file:/Users/fox/Documents/workspace/2020-08-26-Vaadin/vaadin/classes/main-java/
[13.699s][info][class,load] com.vaadin.starter.skeleton.MainView$$Lambda$516/0x0000000800dad040 source: com.vaadin.starter.skeleton.MainView
and the project correctly start in debug mode and works on Visual Studio Code.
The explanation of this change is related to the way Buildship, used by Eclipse and Visual Studo Code, handle the classpath. A good documentation is here as indicated by Donát Csikós: Improved Java project synchronization
Anyway, now is possible to use Visual Studio Code with Jetty embedded managed by Gradle, which is exactly what I was looking to build.
Regards, Stefano
Excellent job finding the workaround! I'm sure it will help all Eclipse and VS Code users tremendously. Thank you so much :+1:
Dear Mvysny,
as requested I am opening a new issue here. I have downloaded your application and imported it in Visual Code Studio. The only modification I did was to add the gradle eclipse plugin to gradle.build in order to let VCS to understand that is a java project.
Running the project with
./gradlew run
it work perfectly but running the project with the debug launching of VCS I have the route error. This is the basic configuration of the debug louncher:The log in the terminal window are:
The supposition is that the debug launcher start the web application is some different way, unfortunately.
I know this is not a common scenario but I will really appreciate if you could point me in the direction of a solution.
Regards, Stefano
P.S. if needed I could send the log in debug mode or the Jetty Dump configuration after the start.