Skip to content

Spotless Maven plugin fails in VS Code m2e build with NoClassDefFoundError: lombok.launch.PatchFixesHider$ModuleClassLoading, but works in CLI Maven #4284

Closed

Description

@CloudSen

Env

System: MacOS 26.1 (25B78)
VSCode: 1.107.0
Plugins:

alefragnani.project-manager-12.8.0
cwan.native-ascii-converter-1.0.9
davidanson.vscode-markdownlint-0.60.0
editorconfig.editorconfig-0.17.4
foxundermoon.shell-format-7.2.8
github.copilot-1.388.0
github.copilot-chat-0.33.5
github.copilot-chat-0.35.0
goessner.mdmath-2.7.4
google.gemini-cli-vscode-ide-companion-0.19.1
hbenl.vscode-test-explorer-2.22.1
huizhou.githd-2.5.7
jebbs.plantuml-2.18.1
johnpapa.read-time-1.0.0
k--kato.intellij-idea-keybindings-1.7.6
kevinrose.vsc-python-indent-1.21.0
littlefoxteam.vscode-python-test-adapter-0.8.2
luanvu.spring-i18n-0.0.4
mechatroner.rainbow-csv-3.23.0
mhutchie.git-graph-1.30.0
ms-python.black-formatter-2025.2.0
ms-python.debugpy-2025.16.0-darwin-arm64
ms-python.python-2025.20.0-darwin-arm64
ms-python.vscode-pylance-2025.10.4
ms-python.vscode-python-envs-1.12.0-darwin-arm64
ms-vscode.test-adapter-converter-0.2.1
ms-vscode.wordcount-0.1.0
njpwerner.autodocstring-0.6.1
openai.chatgpt-0.5.50
openai.chatgpt-0.5.51-darwin-arm64
pkief.material-icon-theme-5.29.0
rdebugger.r-debugger-0.5.5
redhat.java-1.50.0-darwin-arm64
redhat.vscode-xml-0.29.0-darwin-arm64
redhat.vscode-yaml-1.19.1
reditorsupport.r-2.8.6
reditorsupport.r-syntax-0.1.3
shd101wyy.markdown-preview-enhanced-0.8.20
slightc.pip-manager-1.1.4
streetsidesoftware.code-spell-checker-4.2.6
vmware.vscode-boot-dev-pack-0.2.2
vmware.vscode-spring-boot-2.0.2025121100
vscjava.vscode-gradle-3.17.1
vscjava.vscode-java-debug-0.58.2025112507
vscjava.vscode-java-dependency-0.26.5
vscjava.vscode-java-pack-0.30.5
vscjava.vscode-java-test-0.43.2
vscjava.vscode-lombok-1.1.1
vscjava.vscode-maven-0.45.1
vscjava.vscode-spring-boot-dashboard-0.14.2025041702
vscjava.vscode-spring-initializr-0.12.0
vscodevim.vim-1.32.3
waderyan.gitblame-11.2.0
yangbaopan.vscode-java-ibatisx-2024.12.9
yzane.markdown-pdf-1.5.0
yzhang.markdown-all-in-one-3.6.3

Minimal Reproducible POM

maven project: https://github.com/CloudSen/vscode-java-issue-demo

Description

We have a Maven project using spotless-maven-plugin with Eclipse JDT formatter and member sorting enabled.

The project builds successfully when running Maven from the command line (mvn / mvnw), but fails intermittently when built inside the VS Code with Red Hat Java extensions.

This appears to be related to IDE-triggered Maven execution and classloader differences.

Spotless configuration

<plugin>
  <groupId>com.diffplug.spotless</groupId>
  <artifactId>spotless-maven-plugin</artifactId>
  <version>${spotless-maven-plugin.version}</version>
  <configuration>
    <java>
      <eclipse>
        <sortMembersEnabled>true</sortMembersEnabled>
        <sortMembersOrder>SF,SI,SM,F,I,C,M,T</sortMembersOrder>
        <sortMembersVisibilityOrderEnabled>true</sortMembersVisibilityOrderEnabled>
        <sortMembersVisibilityOrder>B,R,D,V</sortMembersVisibilityOrder>
      </eclipse>

      <importOrder>
        <wildcardsLast>false</wildcardsLast>
        <order>,javax,java,#</order>
        <semanticSort>false</semanticSort>
      </importOrder>

      <removeUnusedImports/>
      <trimTrailingWhitespace/>
      <endWithNewline/>
    </java>

    <upToDateChecking>
      <enabled>true</enabled>
      <indexFile>${project.basedir}/spotless-index</indexFile>
    </upToDateChecking>
  </configuration>

  <executions>
    <execution>
      <phase>install</phase>
      <goals>
        <goal>check</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Behavior

Works correctly:

  • ./mvnw clean verify
  • ./mvnw spotless:check

Fails in VSCODE during:

  • automatic build
  • project import
  • refresh / update project
  • java: clean workspace

Error

Failed to execute mojo com.diffplug.spotless:spotless-maven-plugin:2.46.1:check {execution: default} (com.diffplug.spotless:spotless-maven-plugin:2.46.1:check:default:install)

org.eclipse.core.runtime.CoreException: Failed to execute mojo com.diffplug.spotless:spotless-maven-plugin:2.46.1:check {execution: default}
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeMojo(MavenExecutionContext.java:404)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.lambda$2(MavenExecutionContext.java:355)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:458)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:339)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:354)
	at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:57)
	at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.lambda$2(MavenBuilderImpl.java:159)
	at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:986)
	at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:139)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:164)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.lambda$1(MavenBuilder.java:109)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:458)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:292)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.lambda$0(MavenBuilder.java:100)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:458)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:339)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:278)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:83)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:192)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:1109)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:299)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:355)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:449)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:452)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:564)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:512)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:594)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:208)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:309)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to check file /Users/clouds3n/Coding/cisdi/specification/技术委员会/infra/cisdigital-elite-forge-infra-framework/cisdigital-elite-forge-infra-crypto/src/test/java/unit/algorithm/SM2CryptoTest.java
	at com.diffplug.spotless.maven.SpotlessCheckMojo.process(SpotlessCheckMojo.java:94)
	at com.diffplug.spotless.maven.AbstractSpotlessMojo.execute(AbstractSpotlessMojo.java:256)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:126)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeMojo(MavenExecutionContext.java:402)
	... 32 more
Caused by: com.diffplug.spotless.ThrowingEx$WrappedAsRuntimeException: java.lang.reflect.InvocationTargetException
	at com.diffplug.spotless.ThrowingEx.asRuntimeRethrowError(ThrowingEx.java:136)
	at com.diffplug.spotless.Formatter.legacyErrorBehavior(Formatter.java:145)
	at com.diffplug.spotless.DirtyState.of(DirtyState.java:83)
	at com.diffplug.spotless.DirtyState.of(DirtyState.java:77)
	at com.diffplug.spotless.DirtyState.of(DirtyState.java:73)
	at com.diffplug.spotless.maven.SpotlessCheckMojo.process(SpotlessCheckMojo.java:81)
	... 35 more
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at com.diffplug.spotless.extra.java.EclipseJdtFormatterStep.lambda$apply$0(EclipseJdtFormatterStep.java:52)
	at com.diffplug.spotless.FormatterFunc$NeedsFile.apply(FormatterFunc.java:174)
	at com.diffplug.spotless.FormatterStepEqualityOnStateSerialization.format(FormatterStepEqualityOnStateSerialization.java:49)
	at com.diffplug.spotless.Formatter.computeWithLint(Formatter.java:170)
	at com.diffplug.spotless.DirtyState.of(DirtyState.java:97)
	at com.diffplug.spotless.DirtyState.of(DirtyState.java:82)
	... 38 more
Caused by: java.lang.NoClassDefFoundError: lombok/launch/PatchFixesHider$ModuleClassLoading
	at org.eclipse.jdt.internal.compiler.parser.Parser.<clinit>(Parser.java:836)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.parse(CompilationUnitResolver.java:643)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.toCompilationUnit(CompilationUnitResolver.java:1423)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver$ECJCompilationUnitResolver.toCompilationUnit(CompilationUnitResolver.java:109)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateASTCached(ASTParser.java:1395)
	at org.eclipse.jdt.core.dom.ASTParser.lambda$1(ASTParser.java:1274)
	at org.eclipse.jdt.internal.core.JavaModelManager.cacheZipFiles(JavaModelManager.java:5708)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1274)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:918)
	at org.eclipse.jdt.internal.core.SortElementsOperation.processElement(SortElementsOperation.java:148)
	at org.eclipse.jdt.internal.core.SortElementsOperation.executeOperation(SortElementsOperation.java:99)
	at com.diffplug.spotless.extra.glue.jdt.EclipseJdtSortMembers$Sorter.sort(EclipseJdtSortMembers.java:214)
	at com.diffplug.spotless.extra.glue.jdt.EclipseJdtSortMembers.sortMember(EclipseJdtSortMembers.java:73)
	at com.diffplug.spotless.extra.glue.jdt.EclipseJdtFormatterStepImpl.sort(EclipseJdtFormatterStepImpl.java:66)
	at com.diffplug.spotless.extra.glue.jdt.EclipseJdtFormatterStepImpl.format(EclipseJdtFormatterStepImpl.java:51)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	... 45 more
Caused by: java.lang.ClassNotFoundException: lombok.launch.PatchFixesHider$ModuleClassLoading
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
	at com.diffplug.spotless.FeatureClassLoader.findClass(FeatureClassLoader.java:79)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	... 61 more

Activity

  1. Cyber-Oscar commented on Dec 15, 2025

    @Cyber-Oscar

    Fixed in my case, editing settings.json and putting the path of the specified version of lombok in java.project.referencedLibraries". Try to confirm the fix

    Image
  2. CloudSen commented on Dec 15, 2025

    @CloudSen
    Author

    Fixed in my case, editing settings.json and putting the path of the specified version of lombok in java.project.referencedLibraries". Try to confirm the fix

    Image

    The issue still persists. I tried configuring it according to your approach:
    Image

    Image

    It’s worth noting that this issue does not occur 100% of the time. At present, it happens with a very high probability, though occasionally it does not occur. Multiple clean workspace operations may be required to reproduce and verify it.

    And this is my full java configuration:

    "java.jdt.ls.java.home": "<Your Path>/java/21.0.2-zulu",
        "java.autobuild.enabled": true,
        "java.configuration.runtimes": [
            {
                "name": "JavaSE-1.8",
                "path": "<Your Path>/java/8.0.402-zulu",
            },
            {
                "name": "JavaSE-17",
                "path": "<Your Path>/java/17.0.12.fx-zulu"
            },
            {
                "name": "JavaSE-21",
                "path": "<Your Path>/java/21.0.2-zulu",
                "default": true
            }
        ],
        "redhat.telemetry.enabled": false,
        "java.project.referencedLibraries":["/Users/clouds3n/.m2/repository/org/projectlombok/lombok/1.18.42/lombok-1.18.42.jar"],
        "java.jdt.ls.vmargs": "-javaagent:/Users/clouds3n/.m2/repository/org/projectlombok/lombok/1.18.42/lombok-1.18.42.jar",
    
  3. snjeza commented on Dec 18, 2025

    @snjeza
    Collaborator

    @CloudSen Could you try to add "java.jdt.ls.lombokSupport.enabled": false, to settings.js and remove "-javaagent:<lombok>" from "java.jdt.ls.vmargs"?

  4. CloudSen commented on Dec 19, 2025

    @CloudSen
    Author

    @CloudSen Could you try to add "java.jdt.ls.lombokSupport.enabled": false, to settings.js and remove "-javaagent:<lombok>" from "java.jdt.ls.vmargs"?

    If "java.jdt.ls.lombokSupport.enabled": false is used, the pom.xml will not report Lombok-related errors.
    However, all Java classes that use Lombok will report errors.

    Image Image
  5. snjeza commented on Dec 22, 2025

    @snjeza
    Collaborator

    This is an upstream spotless.
    The related issue - diffplug/spotless#2795

  6. snjeza commented on Dec 22, 2025

    @snjeza
    Collaborator

    @CloudSen You can test the PR in the following way:

    $ git clone https://github.com/diffplug/spotless
    $ cd spotless
    $ git fetch origin pull/2796/head:issue-2796
    $ git checkout issue-2796
    $ cd lib
    $ ../gradlew publishToMavenLocal
    

    and update your spotless plugin to 3.2.0-SNAPSHOT.

  7. CloudSen commented on Dec 29, 2025

    @CloudSen
    Author

    @CloudSen You can test the PR in the following way:

    $ git clone https://github.com/diffplug/spotless
    $ cd spotless
    $ git fetch origin pull/2796/head:issue-2796
    $ git checkout issue-2796
    $ cd lib
    $ ../gradlew publishToMavenLocal
    

    and update your spotless plugin to 3.2.0-SNAPSHOT.

    Thanks a lot for the contribution and for providing the testing steps.

    I published issue-2796 both locally and remotely, And updated Spotless to 3.2.0-SNAPSHOT. With this version, the project now builds correctly in VS Code, and the problem I was seeing before is resolved.

    Appreciate the fix 👍.

    I also made a small adjustment on my side to the following line:

    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions