eclipse-lemminx / lemminx-maven

lemminx-maven
Eclipse Public License 2.0
38 stars 31 forks source link

java.lang.NoSuchMethodError: [...] RemoteRepository$Builder.setBlocked(boolean) on completion #360

Closed mfussenegger closed 1 year ago

mfussenegger commented 1 year ago

When triggering completion I'm getting the following error:

java.util.concurrent.CompletionException: java.lang.NoSuchMethodError: 'org.eclipse.aether.repository.RemoteRepository$Builder org.eclipse.aether.repository.RemoteRepository$Builder.setBlocked(boolean)'
    at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
    at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:649)
    at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.NoSuchMethodError: 'org.eclipse.aether.repository.RemoteRepository$Builder org.eclipse.aether.repository.RemoteRepository$Builder.setBlocked(boolean)'
    at org.apache.maven.RepositoryUtils.toRepo(RepositoryUtils.java:213)
    at org.apache.maven.bridge.MavenRepositorySystem.getProxy(MavenRepositorySystem.java:279)
    at org.apache.maven.bridge.MavenRepositorySystem.injectProxy(MavenRepositorySystem.java:310)
    at org.apache.maven.internal.aether.DefaultRepositorySystemSessionFactory.newRepositorySession(DefaultRepositorySystemSessionFactory.java:221)
    at org.eclipse.lemminx.extensions.maven.MavenLemminxExtension.initialize(MavenLemminxExtension.java:174)
    at org.eclipse.lemminx.extensions.maven.MavenLemminxExtension.getLocalRepositorySearcher(MavenLemminxExtension.java:400)
    at org.eclipse.lemminx.extensions.maven.participants.completion.MavenCompletionParticipant.onXMLContent(MavenCompletionParticipant.java:341)
    at org.eclipse.lemminx.services.XMLCompletions.collectInsideContent(XMLCompletions.java:798)
    at org.eclipse.lemminx.services.XMLCompletions.doComplete(XMLCompletions.java:260)
    at org.eclipse.lemminx.services.XMLLanguageService.doComplete(XMLLanguageService.java:162)
    at org.eclipse.lemminx.XMLTextDocumentService.lambda$completion$3(XMLTextDocumentService.java:255)
    at org.eclipse.lemminx.commons.ModelTextDocuments.lambda$computeModelAsync$0(ModelTextDocuments.java:118)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
    ... 6 more

I'm trying to use lemminx-maven in Neovim and suspect I may be missing some dependency in the classpath.

Here's what I did:

Both build fine. I then extracted lemminx-maven/target/lemminx-maven-0.7.1-zip-with-dependencies.zip

Then I start the language server with:

java -cp [...] org.eclipse.lemminx.XMLServerLauncher

Where [...] is the uber jar for lemminx and the jars from the zip-with-dependencies (see full list below)

I puzzled this together from reading some of the vscode-xml extension code (https://github.com/redhat-developer/vscode-xml/blob/efd52ad1f6e89e962c576795c324621aed7d8370/src/server/java/javaServerStarter.ts#L91).

The README here seems a bit outdated so it's unclear what exactly should go into the classpath E.g. the download link is broken: https://download.eclipse.org/technology/m2e/snapshots/1.16.1/latest/ and there are references to vscode-xml-maven which hasn't had a commit in 4 years.

What I have right now is the following. (The cp separates them in the right format with : and they contain the right absolute paths, I list them on a newline each and trimmed the path/to/location for better readability)

JARs included in the classpath ``` lemminx/org.eclipse.lemminx/target/org.eclipse.lemminx-uber.jar lemminx-maven/dist/aether-api-1.1.0.jar lemminx-maven/dist/aether-connector-basic-1.1.0.jar lemminx-maven/dist/aether-connector-okhttp-0.17.8.jar lemminx-maven/dist/aether-spi-1.1.0.jar lemminx-maven/dist/aether-util-1.1.0.jar lemminx-maven/dist/aopalliance-1.0.jar lemminx-maven/dist/commons-cli-1.4.jar lemminx-maven/dist/commons-codec-1.11.jar lemminx-maven/dist/gson-2.8.9.jar lemminx-maven/dist/guice-4.2.2-no_aop.jar lemminx-maven/dist/httpclient-4.5.14.jar lemminx-maven/dist/httpcore-4.4.16.jar lemminx-maven/dist/isorelax-20030108.jar lemminx-maven/dist/javax.annotation-api-1.2.jar lemminx-maven/dist/javax.inject-1.jar lemminx-maven/dist/jcl-over-slf4j-1.7.36.jar lemminx-maven/dist/jing-20220510.jar lemminx-maven/dist/lemminx-maven-0.7.1.jar lemminx-maven/dist/maven-artifact-3.8.7.jar lemminx-maven/dist/maven-builder-support-3.8.7.jar lemminx-maven/dist/maven-compat-3.8.7.jar lemminx-maven/dist/maven-core-3.8.7.jar lemminx-maven/dist/maven-embedder-3.8.7.jar lemminx-maven/dist/maven-model-3.8.7.jar lemminx-maven/dist/maven-model-builder-3.8.7.jar lemminx-maven/dist/maven-plugin-api-3.8.7.jar lemminx-maven/dist/maven-repository-metadata-3.8.7.jar lemminx-maven/dist/maven-resolver-api-1.9.4.jar lemminx-maven/dist/maven-resolver-impl-1.9.4.jar lemminx-maven/dist/maven-resolver-named-locks-1.9.4.jar lemminx-maven/dist/maven-resolver-provider-3.8.7.jar lemminx-maven/dist/maven-resolver-spi-1.9.4.jar lemminx-maven/dist/maven-resolver-util-1.9.4.jar lemminx-maven/dist/maven-settings-3.8.7.jar lemminx-maven/dist/maven-settings-builder-3.8.7.jar lemminx-maven/dist/maven-shared-utils-3.3.4.jar lemminx-maven/dist/okhttp-3.14.1.jar lemminx-maven/dist/okio-1.17.3.jar lemminx-maven/dist/org.eclipse.lemminx-0.23.2.jar lemminx-maven/dist/org.eclipse.lsp4j-0.14.0.jar lemminx-maven/dist/org.eclipse.lsp4j.generator-0.14.0.jar lemminx-maven/dist/org.eclipse.lsp4j.jsonrpc-0.14.0.jar lemminx-maven/dist/org.eclipse.sisu.inject-0.3.5.jar lemminx-maven/dist/org.eclipse.sisu.plexus-0.3.5.jar lemminx-maven/dist/org.eclipse.xtend.lib-2.24.0.jar lemminx-maven/dist/org.eclipse.xtend.lib.macro-2.24.0.jar lemminx-maven/dist/org.eclipse.xtext.xbase.lib-2.24.0.jar lemminx-maven/dist/plexus-cipher-2.0.jar lemminx-maven/dist/plexus-classworlds-2.6.0.jar lemminx-maven/dist/plexus-component-annotations-2.1.0.jar lemminx-maven/dist/plexus-interpolation-1.26.jar lemminx-maven/dist/plexus-sec-dispatcher-2.0.jar lemminx-maven/dist/plexus-utils-3.3.1.jar lemminx-maven/dist/remark-1.0.0.jar lemminx-maven/dist/slf4j-api-1.7.36.jar lemminx-maven/dist/wagon-file-3.5.3.jar lemminx-maven/dist/wagon-http-3.5.3.jar lemminx-maven/dist/wagon-http-shared-3.5.3.jar lemminx-maven/dist/wagon-provider-api-3.5.3.jar lemminx-maven/dist/xercesImpl-2.12.2.jar lemminx-maven/dist/xml-resolver-1.2.jar ```

Using only lemminx/org.eclipse.lemminx/target/org.eclipse.lemminx-uber.jar without the lemminx-maven jars works fine but I'm of course missing the lemminx-maven features.

I'd appreciate any pointers.

mickaelistria commented 1 year ago

At the moment, I'm not aware of any active consumer that is actively using the zip-with-dependencies. In m2e (I fixed the link by the way, thanks for the note), we use the plain jar and use the Maven dependencies libs that are included in m2e itself to add them into the classpath.

This error seems to be that it's not the right version of aether being listed in dependencies here. For reference, here is how the lemminx (+lemminx-maven extension) process is started -successfully- inside my current Eclipse IDE when editing XML files: mistria 488775 0.1 1.7 13574908 559104 ? Sl Feb09 1:10 /home/mistria/apps/eclipse-SDK/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_19.0.2.v20230129-1123/jre/bin/java -Dhttps.nonProxyHosts=localhost|127.0.0.1 -Dhttp.nonProxyHosts=localhost|127.0.0.1 -Dlog.level=FINEST -classpath /home/mistria/apps/eclipse-SDK/configuration/org.eclipse.osgi/882/0/.cp/language-servers/server/org.eclipse.lemminx-uber.jar:/home/mistria/apps/eclipse-SDK/configuration/org.eclipse.osgi/1012/0/.cp/lemminx-maven.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/commons-lang3-3.8.1.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-settings-3.8.7.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/plexus-component-annotations-2.1.0.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/guice-4.2.2-no_aop.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-resolver-impl-1.6.3.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-resolver-connector-basic-1.6.3.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/plexus-sec-dispatcher-2.0.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/aether-connector-okhttp-0.17.8.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/plexus-interpolation-1.26.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/plexus-utils-3.3.1.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/plexus-cipher-2.0.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-builder-support-3.8.7.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/commons-cli-1.4.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-resolver-transport-wagon-1.6.3.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/wagon-provider-api-3.5.3.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-artifact-3.8.7.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-repository-metadata-3.8.7.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-shared-utils-3.3.4.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/jansi-2.4.0.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-resolver-provider-3.8.7.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-resolver-spi-1.6.3.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-model-builder-3.8.7.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-resolver-util-1.6.3.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/org.eclipse.sisu.inject-0.3.5.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/okhttp-3.14.1.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-compat-3.8.7.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-embedder-3.8.7.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/okio-1.17.3.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/plexus-classworlds-2.6.0.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-core-3.8.7.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/org.eclipse.sisu.plexus-0.3.5.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-resolver-api-1.6.3.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-slf4j-provider-3.8.7.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/plexus-build-api-0.0.7.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-plugin-api-3.8.7.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-settings-builder-3.8.7.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/maven-model-3.8.7.jar:/home/mistria/apps/eclipse-SDK/plugins/org.eclipse.m2e.maven.runtime_3.8.700.20230125-0927/jars/wagon-file-3.5.3.jar:/home/mistria/apps/eclipse-SDK/plugins/javax.inject_1.0.0.v20220405-0441.jar:/home/mistria/apps/eclipse-SDK/plugins/slf4j.api_1.7.36.jar org.eclipse.lemminx.XMLServerLauncher I see it's using another version of the resolver and that aether jars are not in.

mfussenegger commented 1 year ago

Thanks for the list of jars. I played around a bit with including/excluding based on the diff of jars and discovered that excluding the aether jar's (except for the connector-okhttp) fixes the issue.

I created a PR that would exclude them: https://github.com/eclipse/lemminx-maven/pull/361

(And in case anyone runs into this and wonders how to get it working with Neovim: here's a playbook with the installation and the Neovim config: https://github.com/mfussenegger/dotfiles/commit/a6c498a6bc7061f0758a4d6ea36a8f2c3e4899df)

mickaelistria commented 1 year ago

It looks like org.eclipse.aether.repository content got merged into maven-resolver-api a while ago and the version from maven-resolver-api must take precedence. If the aether-api jar is in the classpath, it may override the other and better version in maven-resolver-api.