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

Spring Boot properties files code completions is not working #59

Closed
longooh opened this issue Jun 8, 2018 · 18 comments
Closed

Spring Boot properties files code completions is not working #59

longooh opened this issue Jun 8, 2018 · 18 comments
Milestone

Comments

@longooh
Copy link

longooh commented Jun 8, 2018

[2018-06-08 12:31:12.451] [renderer3] [error] Cannot read property 'selection' of undefined: TypeError: Cannot read property 'selection' of undefined
at CursorExploder.explode (C:\Users\wenlong.vscode\extensions\hoovercj.vscode-power-mode-2.2.0\out\src\cursor-exploder\cursor-exploder.js:145:66)
at CursorExploder.onDidChangeTextDocument (C:\Users\wenlong.vscode\extensions\hoovercj.vscode-power-mode-2.2.0\out\src\cursor-exploder\cursor-exploder.js:41:18)
at plugins.forEach.plugin (C:\Users\wenlong.vscode\extensions\hoovercj.vscode-power-mode-2.2.0\out\src\extension.js:119:38)
at Array.forEach (native)
at onDidChangeTextDocument (C:\Users\wenlong.vscode\extensions\hoovercj.vscode-power-mode-2.2.0\out\src\extension.js:119:13)
at e.fire (e:\ide\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:96:764)
at e.$acceptModelChanged (e:\ide\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:686:189)
at e._doInvokeHandler (e:\ide\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:636:832)
at e._invokeHandler (e:\ide\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:636:550)
at e._receiveRequest (e:\ide\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:635:631)
at e._receiveOneMessage (e:\ide\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:635:400)
at e:\ide\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:634:315
at e:\ide\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:637:395
at e:\ide\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:95:432
at e.fire (e:\ide\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:96:764)
at Socket. (e:\ide\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:154:338)
at emitOne (events.js:96:13)
at Socket.emit (events.js:191:7)
at readableAddChunk (_stream_readable.js:178:18)
at Socket.Readable.push (_stream_readable.js:136:10)
at Pipe.onread (net.js:560:20)

@kdvolder
Copy link
Member

kdvolder commented Jun 8, 2018

I have not seen this problem. It looks like an error coming from within vscode's implementation. But its possible this still our (STS language server's) fault somehow.

I think the first thing we need to do is get more details about the versions of 'stuff' that you are using.

I.e. are you on the latest versions of vscode and our extensions? If not, please try to upgrade.

You can check your version of vscode by running

code --version

You can check the version of spring-boot and other extensions from within vscode ui in the same view where you installed them. I can give detailed instructions if you can not figure it out. Let me know.

@longooh
Copy link
Author

longooh commented Jun 11, 2018

C:\Users\rush>code -v
1.24.0
6a6e02cef0f2122ee1469765b704faf5d0e0d859
x64

java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)

I found this warn always output log file
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored
[STS4 Thread-1] INFO org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp - SpringBootApp disposed: Process [id=1756, name=org.codehaus.plexus.classworlds.launcher.Launcher clean]
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored

@kdvolder
Copy link
Member

The error log has nothing worrysome. We know what those warnings mean and they are harmlessly ignored.

Version you have is same as mine. It seems to be working for me.

Do you have the redhat Java support installed alongside the vscode-spring-boot extension?

We just released an update of the vscode-spring-boot last friday. (Version is 0.3.0). If that is the version you are using, it seems to be working for me.

That being said, we are getting the classpath from Java redhat support. And there are some potential hickups around that. If the redhat language support has problems getting classpath our extension will too, and without classpath data, there will be no completions or validations in our editor.

This may be what's happening.

Another possibility is that the java language server isn't started yet. Try to make sure that it is working properly by opening a .java file and check if Java gives content assist when you type in there (i.e. check if the java support is able find types like for example 'SpringApplication' and others like that.

@longooh
Copy link
Author

longooh commented Jun 15, 2018

I aways keep extensions with the latest version. All functionality is ok except when i opening .properties and .yml, the content assist is not working.

I found an error in log file:

[STS4 Thread-1] ERROR org.springframework.ide.vscode.commons.util.Log - Error
java.lang.NullPointerException
at org.springframework.ide.vscode.boot.metadata.IndexNavigator.getExtensionCandidate(IndexNavigator.java:93)
at org.springframework.ide.vscode.boot.metadata.IndexNavigator.isEmpty(IndexNavigator.java:130)
at org.springframework.ide.vscode.boot.yaml.completions.ApplicationYamlAssistContext$IndexContext.traverse(ApplicationYamlAssistContext.java:458)
at org.springframework.ide.vscode.boot.yaml.completions.ApplicationYamlAssistContext$IndexContext.traverse(ApplicationYamlAssistContext.java:386)
at org.springframework.ide.vscode.commons.yaml.path.YamlNavigable.traverseAmbiguously(YamlNavigable.java:45)
at org.springframework.ide.vscode.commons.yaml.path.YamlPath.lambda$traverseAmbiguously$0(YamlPath.java:142)
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:267)
at java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Streams.java:419)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270)
at java.util.stream.Streams$StreamBuilderImpl.tryAdvance(Streams.java:405)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.springframework.ide.vscode.commons.yaml.path.AbstractYamlTraversal.traverse(AbstractYamlTraversal.java:41)
at org.springframework.ide.vscode.commons.yaml.hover.YamlHoverInfoProvider.getHoverInfo(YamlHoverInfoProvider.java:83)
at org.springframework.ide.vscode.boot.properties.BootPropertiesLanguageServerComponents.lambda$getHoverProvider$1(BootPropertiesLanguageServerComponents.java:145)
at org.springframework.ide.vscode.commons.languageserver.hover.VscodeHoverEngineAdapter.handle(VscodeHoverEngineAdapter.java:72)
at org.springframework.ide.vscode.commons.languageserver.composable.CompositeLanguageServerComponents$3.handle(CompositeLanguageServerComponents.java:109)
at org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService.lambda$hover$5(SimpleTextDocumentService.java:301)
at reactor.core.publisher.MonoCallable.call(MonoCallable.java:92)
at reactor.core.publisher.FluxSubscribeOnCallable$CallableSubscribeOnSubscription.run(FluxSubscribeOnCallable.java:225)
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:50)
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:27)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

@martinlippert
Copy link
Member

@lwl19 two more questions... :-)

Are you getting the exception mentioned above ([STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored ) when working with VSCode?

And can you maybe share an example project that reproduces this behavior and the new exception that you posted a moment ago? That would be awesome.

kdvolder added a commit that referenced this issue Jun 15, 2018
See: #59 (comment)

Signed-off-by: Kris De Volder <[email protected]>
@kdvolder
Copy link
Member

kdvolder commented Jun 15, 2018

I pushed a small change that should avoid the NPE. I don't think it will fix the real problem though. We don't really know what it is yet. I'm still thinking it's something about the project somehow interfering with obtain properties metadata.

@lwl19 Does the project build fine when you run a maven build from the commandline? I.e. something like 'mvn clean package'.

Secondly, do you see activity in the log like this:

[STS4 Thread-1] INFO org.springframework.ide.vscode.boot.jdt.ls.JdtLsProjectCache - Project Created: file:/home/kdvolder/tmp/hello-world-service
[STS4 Thread-1] INFO org.springframework.ide.vscode.boot.jdt.ls.JdtLsProjectCache - Classpath has 81 entries 69 source attachements

I'm trying determine if spring-boot extension is obtaining proper classpath data from the java language server.

@martinlippert martinlippert added this to the 4.0.0.M13 milestone Jun 15, 2018
@longooh
Copy link
Author

longooh commented Jun 29, 2018

@martinlippert My project based on Spring Initializr to generate a simple quickstart.
"Change event with bad version ignored"
That warn appeared in my any spring project when working with VSCode.
@kdvolder I guess that is my network interfere with obtain properties metadata. (GWF:https://en.wikipedia.org/wiki/Great_Firewall)

@longooh longooh closed this as completed Jun 29, 2018
@kdvolder
Copy link
Member

kdvolder commented Jul 3, 2018

"Change event with bad version ignored"

This is harmless. Vscode is sending redundant change events sometimes (e.g. when a file is saved for example). Our language server ignores the events and logs a warning, but it shouldn't cause any problems.

I guess that is my network interfere with obtain properties metadata.

It could be, but since the metadata is embedded inside of the project dependencies (in the jar files) there would be other signs of trouble. (E.g. I'd expect you have problems with the general Java file editing completions etc. if the java tooling cannot download the jar dependencies from maven).

@longooh
Copy link
Author

longooh commented Jul 20, 2018

stsjdt.log
vscode-spring-boot-1532072418511.log

I found "/redhat.java/jdt_ws/jdt.ls-java-project/src" and "/redhat.java/jdt_ws/jdt.ls-java-project/bin" is empty folder,that would be signs of trouble.
"executing callback sts4.classpath.GqzfYCCz jdt.ls-java-project false 19".

@kdvolder
Copy link
Member

The logs don't show anything unexpected. So still a mystery what might be the problem. From the file paths I see in the logs, I gather you are on Windows. In theory it shouldn't matter, but we are all on Mac / Linux ourselves so we don't test as much on Windows. It is possible that we have a bug of some kind that makes things not work on Windows. I'm putting a ticket in our internal tracker to remind us to do some windows testing soon.

@Unichron
Copy link

Unichron commented Aug 6, 2018

Hi,
I have the exact same problem. I tested it with the latest version of code and the extension on two different machines running Windows 10. I also updated the jdk to 181, no luck. Tried running code as admin, nothing changed. I tested it with a basic project generated with initializr, no dependencies, no additional code, compiles fine, java autocomplete works fine.

vscode-spring-boot.log:
[main] INFO org.springframework.ide.vscode.commons.util.Log - Starting LS
[main] INFO org.springframework.ide.vscode.commons.util.Log - Connected to parent using socket on port 45556
[STS4 Thread-1] INFO org.springframework.ide.vscode.boot.jdt.ls.JdtLsProjectCache - Project Created: file:/C:/dev/propsdemo
[STS4 Thread-1] INFO org.springframework.ide.vscode.boot.jdt.ls.JdtLsProjectCache - Classpath has 99 entries 82 source attachements
[STS4 Thread-1] INFO org.springframework.ide.vscode.boot.jdt.ls.JdtLsProjectCache - Project Created: file:/C:/Users/Uni/AppData/Roaming/Code/User/workspaceStorage/7920618386cb2287750eeae935ff2ca3/redhat.java/jdt_ws/jdt.ls-java-project
[STS4 Thread-1] INFO org.springframework.ide.vscode.boot.jdt.ls.JdtLsProjectCache - Classpath has 19 entries 7 source attachements
[STS4 Thread-1] WARN org.springframework.ide.vscode.commons.util.Log - Change event with bad version ignored

@martinlippert
Copy link
Member

This is indeed strange. Can you attach the sample project? Just curious to double check the exact same project here to see if this is related to the environment or to something else.

@Unichron
Copy link

Unichron commented Aug 7, 2018

It's just a default generated project from https://start.spring.io/, didn't change a bit.

@kdvolder
Copy link
Member

kdvolder commented Aug 7, 2018

I think both @Unichron and @lwl19 are on Windows. So I will do some Window's testing today. I'll have to set things up on a VM. It seems the most likely explanation is some type of bug that breaks things on Windows.

@kdvolder kdvolder reopened this Aug 7, 2018
@kdvolder
Copy link
Member

kdvolder commented Aug 7, 2018

I'm trying it right now on Windows 10 VM and I can confirm that it is also not working for me.

Steps I did to reproduce this:

  • startup vscode
  • use the intializer extension from miscrosoft (installed via vscode marketplace) to create a simple boot app with actuator and web dependencies.
  • open main java file in vscode editor. Allow some time to initialize various stuff in java language server.
  • open application.properties
  • try invoking some completions.
    => no suggestions.

At first glance, from the output in server log it seems like the language server is receiving classpath data. I will have to setup a debug environment to see what it actually does with the data and try to determine where/if/why it might be going wrong reading metadata from the classpath jars.

@kdvolder
Copy link
Member

kdvolder commented Aug 7, 2018

Problem appears to be caused by a discrepeancy between the case (upper vs lower) of the drive-letter for uris of projects and documents. These uris come to us from different sources (one from vscode client and the other from jdt language server).

It seems that the uris end up being different. One ends up being like this: file:/C:/... where the other is file:/c:/... instead.

This makes it so that when a completion request comes in for a given document uri, when we go looking for the corresponding project, we don't find it (because of the mismatched drive-letters).

@martinlippert martinlippert modified the milestones: 4.0.0.M13, 4.0.0.M14 Aug 8, 2018
@kdvolder
Copy link
Member

kdvolder commented Aug 8, 2018

Tested with latest snapshot build. Is working now for me. There will be new release on vscode marketplace in a couple of days (tomorrow, if all goes according to plan :-).

If you want to test it now rather than wait, you can install the snapshot which you can download here:

http://dist.springsource.com/snapshot/STS4/nightly-distributions.html

Instructions on installing a .vsix file here (near bottom of the page): https://github.com/spring-projects/sts4/blob/master/vscode-extensions/vscode-spring-boot/README.md

@Unichron
Copy link

Unichron commented Aug 9, 2018

Yes it's also working for me with the latest nightly build. Thanks!

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