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

Live application information hovers not available #395

Closed
evowilliamson opened this issue Dec 13, 2019 · 14 comments
Closed

Live application information hovers not available #395

evowilliamson opened this issue Dec 13, 2019 · 14 comments

Comments

@evowilliamson
Copy link

evowilliamson commented Dec 13, 2019

Hi!

I am having issues with seeing live application hovers in the Spring Boot Tools extension.

My environment:
Ubuntu 18.04
Visual Studio Code
JAVA_HOME: /usr/lib/jvm/java-11-openjdk-amd64
App: https://github.com/spring-projects/spring-petclinic

I've installed the Spring Boot Tools, latest version as of now.

I checked the vscode-spring-boot-debug-log and it doesn't look good:

Activating 'vscode-spring-boot' extension
Found java exe: /usr/lib/jvm/java-11-openjdk-amd64/bin/java
isJavaEightOrHigher => true
Redirecting server logs to /dev/null
ERR: Disabling server log output. No more output will be sent after this.
ERR:

Child process connected on port 45556

When I hover over a section in java file, I see an error in the Log(Window):

[2019-12-13 15:22:48.931] [renderer1] [error] The request (id: 55, method: 'textDocument/hover') has been cancelled: Error: The request (id: 55, method: 'textDocument/hover') has been cancelled
at /home/ivo/.vscode/extensions/redhat.java-0.54.2/dist/extension.js:1:72946
at /home/ivo/.vscode/extensions/redhat.java-0.54.2/dist/extension.js:1:73240
at Immediate. (/home/ivo/.vscode/extensions/redhat.java-0.54.2/dist/extension.js:1:73601)
at processImmediate (internal/timers.js:439:21)

logs.zip

I've attached both logs

@kdvolder
Copy link
Member

kdvolder commented Dec 16, 2019

The info in the logs is not very interesting. The one in 'WINDOW' appears to be from the Redhat Java extensions so has not much relation to problems in the spring boot language server.

The `vscode-spring-boot-debug-log' basically just has an information message saying that logging has been disabled.

To get more interesting log output you can enable the log output via a preference. For example something like his in settings.json:

{
    "spring-boot.ls.logfile": "/tmp/boot-ls-log.txt"
}

I think I know why you are not getting the live hover information though. A few things have changed both in spring boot and in the tooling.

Firstly, in spring boot, the jmx support is no longer enabled by default in recent versions (which the Petclinic app uses). So something/someone has to enable it explicitly when you launch the app. This happens automatically for apps launched from the Eclipse Boot Dashboard. For any other kind of launch you have to do it yourself. For example when I launch the PetClinic app from the commandline I do it like this:

 java -Dspring.jmx.enabled=true -Dspring.application.admin.enabled=true -jar target/spring-petclinic-2.2.0.BUILD-SNAPSHOT.jar

How did you launch the petclinic app? Did you enable JMX in spring?

Secondly, in the spring-boot tooling, the language server no longer auto connects to most processes (apps launched from Eclipse Boot Dashboard are an exception). You have to do that explicitly. In vscode you do this as follows:

  • Press CTRL-SHIFT-P
  • Type 'live'
  • Select command 'Manage Live Boot Process Connections'
  • Select a process and connect to it.

Perhaps with this additional information you are able to get it working?

If not, we can try trouble shoot more. In that case:

  • please describe exactly what you are doing (how you launch the app, how you connect to the process etc.)
  • please enable logging and then include the log output from the language server.

@kdvolder
Copy link
Member

@evowilliamson If you have a chance to try... could you let us know if after enabling JMX for petclinic and using the 'Manage Live Boot Process Connections' command in vscode to connect to the process... things work as expected?

In the mean time I'll assume that is the case and close this ticket. But we can of course re-open it and take another look if you are still experiencing problems.

@evowilliamson
Copy link
Author

@kdvolder I will try today. I'll have some time after the break!

@evowilliamson
Copy link
Author

evowilliamson commented Dec 18, 2019

@kdvolder,

When I mvn install the app and start the app from a terminal in the workspace, activating jmx in spring boot, and after selecting the live spring boot process, all is OK.

But when I start the process by right-clicking the spring-petclinic option in the SPRING-BOOT-DASHBOARD, things go wrong at the moment of selecting the live spring boot process.

I've included the boot-ls-log.txt file that contains the errors. I've also included my launch.json file that I use to spin off the debug process.
debug.zip

Is there anything wrong with how I am providing the -D args to the process ? I've also tried splitting up the string in different elements in the list, but I got the same result: "args": [
"-Dspring.jmx.enabled=true", "-Dspring.application.admin.enabled=true"
]

Thanks in advance!

@kdvolder
Copy link
Member

kdvolder commented Dec 18, 2019

I think the -D arguments are not arguments to your app but arguments to the JVM itself so you have to put them as 'vmArgs' not 'args'.

I.e. if you look at how it is launched on the CLI:

java ..vmArgs... -jar target/spring-petclinic-2.2.0.BUILD-SNAPSHOT.jar ..args...

You will see that the -D arguments where placed right afther the java executable and before the -jar. This is where the so called 'vmArgs' are.

Also... yes I think in the launch.json file you put the arguments split up individually into a json list rather than as just one long string.

@evowilliamson
Copy link
Author

@kdvolder

Splitting up both arguments in array values, resulted in an error:

{ "type": "java", "name": "Debug (Launch)-PetClinicApplication<spring-petclinic>", "request": "launch", "cwd": "${workspaceFolder}", "console": "internalConsole", "stopOnEntry": false, "mainClass": "org.springframework.samples.petclinic.PetClinicApplication", "projectName": "spring-petclinic", "vmArgs": [ "-Dspring.jmx.enabled=true", "-Dspring.application.admin.enabled=true" ] }

Caused by: java.lang.IllegalArgumentException: Invalid boolean value 'true,-Dspring.application.admin.enabled=true'

Moving both arguments in the same string, results in no errors, but doesn't give me the live application hovers:

{ "type": "java", "name": "Debug (Launch)-PetClinicApplication<spring-petclinic>", "request": "launch", "cwd": "${workspaceFolder}", "console": "internalConsole", "stopOnEntry": false, "mainClass": "org.springframework.samples.petclinic.PetClinicApplication", "projectName": "spring-petclinic", "vmArgs": "-Dspring.jmx.enabled=true -Dspring.application.admin.enabled=true" }

@kdvolder
Copy link
Member

@evowilliamson That's odd I just tried it myself. Here's the complete contents of my launch.json file for reference:

{
    // 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)-PetClinicApplication<spring-petclinic>",
            "request": "launch",
            "cwd": "${workspaceFolder}",
            "console": "internalConsole",
            "stopOnEntry": false,
            "mainClass": "org.springframework.samples.petclinic.PetClinicApplication",
            "projectName": "spring-petclinic",
            "args": "",
            "vmArgs": [ "-Dspring.jmx.enabled=true", "-Dspring.application.admin.enabled=true" ]
        },
        {
            "type": "java",
            "name": "Debug (Attach)",
            "request": "attach",
            "hostName": "localhost",
            "port": 0
        }
    ]
}

I launched the Java app via the 'Run' codelens that appears in the main '.java' file next to the 'main' method. This launched fine. I then connected to the process using jconsole and verified on its 'VM Summary' tab that the vmarguments were present and they were. Finally, I use the 'Manage Live Boot Process Connections' command to connect to the process for live data... and live hovers started to appear. (E.g. for a concrete example '@SpringBootApplication' annotation in 'PetClinicApplication.java' became highlighted and hovering over it revealed expected information).

@kdvolder
Copy link
Member

Aha! Okay so when I launch with the above launch.json from the Boot Dashboard 'play' button instead of using the 'Run' codelens then I do get an error. So maybe this could be a bug in the Boot Dashboard.

I suspect the boot dash launch may be passing something funky for the vmarguments. Unfortunately its not that easy to check what was passed as, when the process errors it exits and so I don't get the chance to connect jconsole to take a look.

@kdvolder
Copy link
Member

Okay, I just put a waitloop in the start of my main method so process doesn't error and I have time to inspect what's in JVM args. This is what I found for vmArgs:

-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=35473 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost -Dspring.application.admin.enabled=true -Dspring.jmx.enabled=true,-Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 

Looks like Boot dashboard launch (or something else?) added some arguments of its own and then merged in the ones from our launch.json file. But in doing so it put a , between -Dspring.jmx.enable=true and -Dspring.application.admin.enabled=true. This of course changes the meaning of those arguments, and that causes the error in spring boot.

I don't think this is a bug in STS 4, but I'll follow up on this and try and get this properly debugged/fixed.

As a workaround for now, I think you can just omit the second vm argument. "-Dspring.application.admin.enabled=true" because boot dash also sets that already, so its kind of redundant for you/us to set it as well. When we only set a single argument, no spurrious comma is added and everything seems to work fine.

@kdvolder
Copy link
Member

For reference, this launch.json file works for me (with Boot Dash launch):

{
    // 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)-PetClinicApplication<spring-petclinic>",
            "request": "launch",
            "cwd": "${workspaceFolder}",
            "console": "internalConsole",
            "stopOnEntry": false,
            "mainClass": "org.springframework.samples.petclinic.PetClinicApplication",
            "projectName": "spring-petclinic",
            "args": "",
            "vmArgs": "-Dspring.jmx.enabled=true"
        },
        {
            "type": "java",
            "name": "Debug (Attach)",
            "request": "attach",
            "hostName": "localhost",
            "port": 0
        }
    ]
}

@kdvolder
Copy link
Member

I also tried putting all the VMArgs into a single string and that also appears to work fine. It does add the -Dspring.application.admin.enabled=true part twice, but that seems to have no ill effect. I am able to connect to the process and get live hovers.

Anyhow... how it deals with the arguments when placed in a list is still a bug.

@evowilliamson
Copy link
Author

For reference, this launch.json file works for me (with Boot Dash launch):

{
    // 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)-PetClinicApplication<spring-petclinic>",
            "request": "launch",
            "cwd": "${workspaceFolder}",
            "console": "internalConsole",
            "stopOnEntry": false,
            "mainClass": "org.springframework.samples.petclinic.PetClinicApplication",
            "projectName": "spring-petclinic",
            "args": "",
            "vmArgs": "-Dspring.jmx.enabled=true"
        },
        {
            "type": "java",
            "name": "Debug (Attach)",
            "request": "attach",
            "hostName": "localhost",
            "port": 0
        }
    ]
}

Just using the single
"vmArgs": "-Dspring.jmx.enabled=true"
does the trick for me!

@Eskibear
Copy link
Contributor

@kdvolder
As far as I know, Live Hover information is one of the most appealing features. Since it has been blocked by the upstream project (spring-boot), can we add some user guides into README section live-application-information-hovers. E.g., something like:

⚠️ To get the live hover info working, you have to add "vmArgs": "-Dspring.jmx.enabled=true" mannually in launch.json, or launch the app directly from the boot dashboard extension.

I think it will be helpful when others have the same problem.

@martinlippert
Copy link
Member

@Eskibear Totally agree, I updated the VSCode readme in 3dcb2d4

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

4 participants