spring-projects / sts4

The next generation of tooling for Spring Boot, including support for Cloud Foundry manifest files, Concourse CI pipeline definitions, BOSH deployment manifests, and more... - Available for Eclipse, Visual Studio Code, and Theia
https://spring.io/tools
Eclipse Public License 1.0
858 stars 199 forks source link

Suddenly getting continuous "ClassNotFoundException: org.springframework.ide.vscode.boot.app.SpringSymbolIndex$2" errors #1291

Closed davidmichaelkarr closed 2 weeks ago

davidmichaelkarr commented 2 weeks ago

I've been using Eclipse 2024-06 and many previous versions before that. I appear to have version "4.23.1.202406141939" of "Spring Tool Suite 4 Main Feature", and a similar version string for the Language Server and Dash (LSF seems to be from the previous day).

What I've had has worked reasonably well for quite a while, with occasional minor issues.

Last Friday, my laptop had a hard disk error and had to be reimaged, and as much as possible was restored from backup. When I logged back in, it seemed to be mostly all restored, but I found that when I started Eclipse, it would say "Initializing language server ..." basically forever. I finally turned on the console log for the LS, and I saw this:

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1443)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1353)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:784)
    ... 19 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/ide/vscode/boot/app/SpringSymbolIndex$2
    at org.springframework.ide.vscode.boot.app.SpringSymbolIndex.afterPropertiesSet(SpringSymbolIndex.java:169)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1835)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1784)
    ... 29 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.ide.vscode.boot.app.SpringSymbolIndex$2
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
    ... 32 common frames omitted```

I've tried creating a new workspace, which made no difference. It's sort of odd that it's complaining about a missing class associated with "vscode". I do also have vscode installed, but I've had that for quite a while, but I don't work on Java code with that.

I did a simple-minded search of the Eclipse distro for jar files with "org.springframework.ide.vscode" in them, and I found this:

./configuration/org.eclipse.osgi/631/0/.cp/lib/commons-lsp-extensions.jar: META-INF/maven/org.springframework.ide.vscode/commons-lsp-extensions/
./configuration/org.eclipse.osgi/631/0/.cp/lib/commons-lsp-extensions.jar: META-INF/maven/org.springframework.ide.vscode/commons-lsp-extensions/pom.xml
./configuration/org.eclipse.osgi/631/0/.cp/lib/commons-lsp-extensions.jar: META-INF/maven/org.springframework.ide.vscode/commons-lsp-extensions/pom.properties

I have no idea whether this is significant.

martinlippert commented 2 weeks ago

This exception seems to happen inside of the Spring Boot language server, which is an external process being started by the IDE in the background. The code for the external process is located in the plugin org.springframework.tooling.boot.ls in the servers directory, which has a somewhat deep folder structure. From your description, it looks like files in that deep structure got corrupted or not restored correctly.

A possible solution for this would be to re-install a fresh STS distribution and go from there. Another solution that you could try would be to extract a fresh install into a different location and just replace everything in that servers folder with the fresh install. This is - of course - not the recommended way of fixing this, but you could give it a try.

davidmichaelkarr commented 2 weeks ago

I tried uninstalling all the "spring" plugins and reinstalling from the marketplace, no change. I'll try a completely new install.

davidmichaelkarr commented 2 weeks ago

And now, after reinstalling 2024-06 completely, including the plugins from the marketplace that I always install, and then importing my projects from git, I am still getting the same error. Next thing to try? I was considering finding the classes in this stack trace and decompiling them and seeing if I can find a clue in the decompiled code.

BoykoAlex commented 2 weeks ago

When you r IDE is running can you open jconsole and find a process with name org.springframework.ide.vscode.boot.app.BootLanguageServerBootApp. Hopefully there is only one around. Otherwise kill all of them and restart STS. Explore the VM Summary tab. Check the JVM running the process, look at the classpath entries. Check if you have an entry with path ending with: /Eclipse/plugins/org.springframework.tooling.boot.ls_1.56.0.202406131359/servers/spring-boot-language-server/BOOT-INF/classes | Eclipse/plugins/org.springframework.tooling.boot.ls_1.56.0.202406131359/servers/spring-boot-language-server/BOOT-INF/classes Check if the folder has content in the file system. Would be nice to see a screenshot of the vm summary tab as well...

What about just the STS 4.23.1 distro without any extra plugins downloaded from https://spring.io/tools? Do you get the same issue with "vanilla" STS distro?

davidmichaelkarr commented 2 weeks ago

Something is definitely odd here. I did see a Java process running a language server with "lemminx" in the classname. I killed that and restarted Eclipse. I'm now not seeing any other java process. I'm going to try to rename ~/.p2 and reinstall eclipse.

davidmichaelkarr commented 2 weeks ago

Ok, well, not sure what was wrong here, but I think I've got this fixed. I did attempt to run the "Bundle Pools" option in the installer and look for damaged artifacts, but it didn't find any. So, I simply renamed the ~/.p2 directory and reinstalled Eclipse and all of my plugins. No more LS errors.

martinlippert commented 2 weeks ago

Ok, glad to heat that you got this fixed. Closing this item.