revelc/formatter-maven-plugin

Not able to run validate due to ExtensionRegistry return null value

Closed this issue · 4 comments

Describe the bug
I integrated the formatter, but executing mvn formatter:validate returns this error:

[ERROR] Failed to execute goal net.revelc.code.formatter:formatter-maven-plugin:2.23.0:validate (default-cli) on project tester: Execution default-cli of goal net.revelc.code.formatter:formatter-maven-plugin:2.23.0:validate failed: Cannot invoke "org.eclipse.core.runtime.IExtensionRegistry.getExtensionPoint(String, String)" because the return value of "org.eclipse.core.runtime.Platform.getExtensionRegistry()" is null -> [Help 1]

Versions (OS, Maven, Java, and others, as appropriate):

  • Affected version(s) of this project: 2.23.0
  • Java version: 17.0.5, vendor: Eclipse Adoptium
  • Apache Maven 3.8.8
  • OS: Xubuntu / x86_64 Linux 6.2.0-36-generic

Integration in maven:

	<build>
		<plugins>
			<plugin>
				<groupId>net.revelc.code.formatter</groupId>
				<artifactId>formatter-maven-plugin</artifactId>
				<version>2.23.0</version>
				<configuration>
					<configFile>${project.basedir}/eclipse-style.xml</configFile>
					<overrideConfigCompilerVersion>true</overrideConfigCompilerVersion>
					<compilerSource>1.17</compilerSource>
					<compilerCompliance>1.17</compilerCompliance>
					<compilerTargetPlatform>1.17</compilerTargetPlatform>
				</configuration>
			</plugin>
		</plugins>
	</build>

To Reproduce
Steps to reproduce the behavior (or a link to an example repository that reproduces the problem):

  1. Performing mvn formatter:validate (mvn formatter:format creates the same error, only mvn formatter:help works)

Expected behavior
Working pluging and no exception

@galan There's no such Java version as 1.17. Change it to 17, and let us know if that works (will close in the meantime).

Thanks for the hint, but unfortunately, the same error persists. @ctubbsii

[ERROR] Failed to execute goal net.revelc.code.formatter:formatter-maven-plugin:2.23.0:validate (default-cli) on project tester: Execution default-cli of goal net.revelc.code.formatter:formatter-maven-plugin:2.23.0:validate failed: Cannot invoke "org.eclipse.core.runtime.IExtensionRegistry.getExtensionPoint(String, String)" because the return value of "org.eclipse.core.runtime.Platform.getExtensionRegistry()" is null -> [Help 1]

I could not reproduce the error, but I don't have your config file. I google'd for the error, and came across a similar issue, diffplug/spotless#1638 (comment), which pointed us back to our own issue #621 (comment)

So, I suspect your config file is not valid or is not compatible with the version of Eclipse JDT that this plugin is using. You can try importing your config file, and re-exporting it, from the corresponding Eclipse version for this plugin version.

Yes, regarding your version compatibility sheet, this maven plugin does not cover the current eclipse verions. My version:

Eclipse IDE for Java Developers (includes Incubating components)
Version: 2023-09 (4.29.0)
Build id: 20230907-1323
OS: Linux, v.6.2.0-37-generic, x86_64 / gtk 3.24.33, WebKit 2.42.2
Java vendor: Eclipse Adoptium
Java runtime version: 17.0.9+9
Java version: 17.0.9

However, I downloaded Eclipse 2023-03 (4.27.0) and did an export for the older version, but the result was the same error as above.

Then I tested the hint from #621 (comment) and it turned out, that removing the following line also helped removing the error.

<setting id="org.eclipse.jdt.core.javaFormatter" value="org.eclipse.jdt.core.defaultJavaFormatter"/>