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

Visual Code Studio @Route error #4

Closed
foxpluto opened this issue Aug 28, 2020 · 8 comments
Closed

Visual Code Studio @Route error #4

foxpluto opened this issue Aug 28, 2020 · 8 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@foxpluto
Copy link

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:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Debug (Launch) - Current File",
            "request": "launch",
            "mainClass": "${file}"
        },
        {
            "type": "java",
            "name": "Vaadin Gradle",
            "request": "launch",
            "mainClass": "com.vaadin.starter.skeleton.ManualJetty",
            "projectName": "vaadinGradle"
        }
    ]
}

The log in the terminal window are:

 /Library/Java/JavaVirtualMachines/adoptopenjdk-13.jre/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:52540 -Dfile.encoding=UTF-8 @/var/folders/p1/lb5grfpn3tncxdtrptqq9fw40000gp/T/cp_1aqukurisa3qpe150j8zkk6rx.argfile com.vaadin.starter.skeleton.ManualJetty 
bash-3.2$  /Library/Java/JavaVirtualMachines/adoptopenjdk-13.jre/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:52540 -Dfile.encoding=UTF-8 @/var/folders/p1/lb5grfpn3tncxdtrptqq9fw40000gp/T/cp_1aqukurisa3qpe150j8zkk6rx.argfile com.vaadin.starter.skeleton.ManualJetty 
2020-08-28 19:02:01.240 [main] INFO org.eclipse.jetty.util.log - Logging initialized @552ms to org.eclipse.jetty.util.log.Slf4jLog
/webapp/ROOT is file:/Users/fox/Documents/workspace/vaadin14-embedded-jetty-gradle-master/bin/main/webapp/ROOT
WebRoot is file:/Users/fox/Documents/workspace/vaadin14-embedded-jetty-gradle-master/bin/main/webapp
2020-08-28 19:02:01.441 [main] INFO org.eclipse.jetty.server.Server - jetty-9.4.31.v20200723; built: 2020-07-23T17:57:36.812Z; git: 450ba27947e13e66baa8cd1ce7e85a4461cacc1d; jvm 13.0.2+8
2020-08-28 19:02:02.041 [main] INFO org.eclipse.jetty.annotations.AnnotationConfiguration - Scanning elapsed time=405ms
2020-08-28 19:02:02.047 [main] INFO org.eclipse.jetty.webapp.StandardDescriptorProcessor - NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2020-08-28 19:02:02.061 [main] INFO org.eclipse.jetty.server.handler.ContextHandler.ROOT - Initializing AtmosphereFramework
2020-08-28 19:02:02.147 [main] INFO com.vaadin.flow.server.startup.DevModeInitializer - Starting dev-mode updaters in /Users/fox/Documents/workspace/vaadin14-embedded-jetty-gradle-master folder.
2020-08-28 19:02:02.212 [main] INFO dev-updater - Visited 86 classes. Took 46 ms.
2020-08-28 19:02:02.237 [main] INFO dev-updater - Skipping `pnpm install`.
2020-08-28 19:02:02.237 [main] INFO dev-updater - Copying frontend resources from jar files ...
2020-08-28 19:02:02.276 [main] INFO dev-updater - Visited 12 resources. Took 39 ms.
2020-08-28 19:02:02.305 [main] INFO dev-updater - No js modules to update '/Users/fox/Documents/workspace/vaadin14-embedded-jetty-gradle-master/target/frontend/generated-flow-imports.js' file

------------------ Starting Frontend compilation. ------------------
2020-08-28 19:02:04.651 [main] INFO dev-webpack - Running webpack to compile frontend resources. This may take a moment, please stand by...
2020-08-28 19:02:07.282 [main] INFO dev-webpack - Started webpack-dev-server. Time: 145189778ms
2020-08-28 19:02:07.313 [main] INFO org.eclipse.jetty.server.session - DefaultSessionIdManager workerName=node0
2020-08-28 19:02:07.313 [main] INFO org.eclipse.jetty.server.session - No SessionScavenger set, using defaults
2020-08-28 19:02:07.315 [main] INFO org.eclipse.jetty.server.session - node0 Scavenging every 600000ms
2020-08-28 19:02:07.329 [main] WARN com.vaadin.flow.server.startup.ServletDeployer - Skipping automatic servlet registration because there are no navigation targets registered to the route registry and there are no web component exporters.
2020-08-28 19:02:07.401 [main] WARN com.vaadin.flow.server.startup.ServletDeployer - Skipping automatic servlet registration because there are no navigation targets registered to the route registry and there are no web component exporters.
2020-08-28 19:02:07.401 [main] WARN com.vaadin.flow.server.communication.JSR356WebsocketInitializer - Atmosphere already initialized
2020-08-28 19:02:07.410 [main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.w.WebAppContext@5a7005d{/,[file:///Users/fox/Documents/workspace/vaadin14-embedded-jetty-gradle-master/bin/main/webapp/, jar:file:///Users/fox/.gradle/caches/modules-2/files-2.1/com.vaadin/flow-dnd/2.3.2/4e9df680c15bcf49118065417036dc88f421d00a/flow-dnd-2.3.2.jar!/META-INF/resources, jar:file:///Users/fox/.gradle/caches/modules-2/files-2.1/com.vaadin/vaadin-menu-bar-flow/1.1.0/4cdd9c988d8667302b713a561abc8a5e241f35fa/vaadin-menu-bar-flow-1.1.0.jar!/META-INF/resources, jar:file:///Users/fox/.gradle/caches/modules-2/files-2.1/org.webjars.npm/mobile-drag-drop/2.3.0-rc.1/a99efeb0c4378d66787d060aa30a3f39adfee659/mobile-drag-drop-2.3.0-rc.1.jar!/META-INF/resources, jar:file:///Users/fox/.gradle/caches/modules-2/files-2.1/com.vaadin/vaadin-select-flow/2.1.0/d66f591333a710c97f6777fe452e6f309db7a479/vaadin-select-flow-2.1.0.jar!/META-INF/resources, jar:file:///Users/fox/.gradle/caches/modules-2/files-2.1/com.vaadin/vaadin-context-menu-flow/3.2.0/bb7eb3c2ea4d23e3cec5b41d2d42c498097bf3e7/vaadin-context-menu-flow-3.2.0.jar!/META-INF/resources, jar:file:///Users/fox/.gradle/caches/modules-2/files-2.1/com.vaadin/vaadin-date-picker-flow/2.1.0/5c1f5738eba5b584846a99a27267892dc71d8c9a/vaadin-date-picker-flow-2.1.0.jar!/META-INF/resources, jar:file:///Users/fox/.gradle/caches/modules-2/files-2.1/com.vaadin/flow-data/2.3.2/7b80fa36b4967bfec1cc9dfbbdf14be24fd86dce/flow-data-2.3.2.jar!/META-INF/resources, jar:file:///Users/fox/.gradle/caches/modules-2/files-2.1/com.vaadin/vaadin-grid-flow/4.2.1/ab4680a3cbe935abbec4c989635743010c84301/vaadin-grid-flow-4.2.1.jar!/META-INF/resources, jar:file:///Users/fox/.gradle/caches/modules-2/files-2.1/com.vaadin/vaadin-iron-list-flow/2.1.0/b6f0b7de7503a09c6957adf5bb814900cb82ccb9/vaadin-iron-list-flow-2.1.0.jar!/META-INF/resources, jar:file:///Users/fox/.gradle/caches/modules-2/files-2.1/com.vaadin/vaadin-time-picker-flow/2.2.0/611ba6ae378feb3a05b596eaa562060fdb1fa2e6/vaadin-time-picker-flow-2.2.0.jar!/META-INF/resources, jar:file:///Users/fox/.gradle/caches/modules-2/files-2.1/org.webjars.npm/vaadin__vaadin-mobile-drag-drop/1.0.0/f59b817abc4afaf3a4011e29d37d30a21e3568a5/vaadin__vaadin-mobile-drag-drop-1.0.0.jar!/META-INF/resources, jar:file:///Users/fox/.gradle/caches/modules-2/files-2.1/com.vaadin/flow-client/2.3.2/d9695f5dbb8b50aebc49cf74534c93b92bfee9fb/flow-client-2.3.2.jar!/META-INF/resources, jar:file:///Users/fox/.gradle/caches/modules-2/files-2.1/com.vaadin/flow-server/2.3.2/9ae93697a9622c2433dd7a70f4b6eb02d0b820d6/flow-server-2.3.2.jar!/META-INF/resources, jar:file:///Users/fox/.gradle/caches/modules-2/files-2.1/com.vaadin/vaadin-text-field-flow/2.2.0/d1cfd7e2bdbb56eef14db134ee53b720620e1fd3/vaadin-text-field-flow-2.2.0.jar!/META-INF/resources, jar:file:///Users/fox/.gradle/caches/modules-2/files-2.1/com.vaadin/vaadin-combo-box-flow/3.1.0/87827c3f5e814e7c559e47d9f89d1766e3f76327/vaadin-combo-box-flow-3.1.0.jar!/META-INF/resources, jar:file:///Users/fox/.gradle/caches/modules-2/files-2.1/com.vaadin/flow-push/2.3.2/317cfcf12ae6d1d581ddd2886858c33301ac5987/flow-push-2.3.2.jar!/META-INF/resources],AVAILABLE}
2020-08-28 19:02:07.424 [main] INFO org.eclipse.jetty.server.AbstractConnector - Started ServerConnector@1a052a00{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2020-08-28 19:02:07.425 [main] INFO org.eclipse.jetty.server.Server - Started @6742ms


=================================================

Please open http://localhost:8080 in your browser

If you see the 'Unable to determine mode of operation' exception, just kill me and run `./gradlew vaadinPrepareFrontend`

=================================================

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.

@mvysny
Copy link
Owner

mvysny commented Aug 28, 2020

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?

@mvysny mvysny self-assigned this Aug 28, 2020
@mvysny mvysny added the question Further information is requested label Aug 28, 2020
@foxpluto
Copy link
Author

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.

@foxpluto
Copy link
Author

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.

@mvysny mvysny added bug Something isn't working help wanted Extra attention is needed and removed question Further information is requested labels Aug 31, 2020
@mvysny
Copy link
Owner

mvysny commented Aug 31, 2020

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 👍

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.

@foxpluto
Copy link
Author

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.

@mvysny
Copy link
Owner

mvysny commented Aug 31, 2020

No problem 👍 best of luck!

@foxpluto
Copy link
Author

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

@mvysny
Copy link
Owner

mvysny commented Sep 11, 2020

Excellent job finding the workaround! I'm sure it will help all Eclipse and VS Code users tremendously. Thank you so much 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants