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

Exception opening a Spring Initializr project template #8054

Open
kz282 opened this issue Dec 14, 2024 · 8 comments · May be fixed by #8057
Open

Exception opening a Spring Initializr project template #8054

kz282 opened this issue Dec 14, 2024 · 8 comments · May be fixed by #8057
Labels
Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) kind:bug Bug report or fix Maven [ci] enable "build tools" tests pending-response Awaiting further information to be supplied

Comments

@kz282
Copy link

kz282 commented Dec 14, 2024

Apache NetBeans version

Apache NetBeans 24 release candidate

What happened

I have created a Spring Boot project on Spring Initializr and opened it both with Netbeans 22 and 24.
Syntax highlight works, syntax check, autocomplete, class import suggestion and some of other features don't.
I can run maven "spring-boot:run" from the goals and it starts the application.

The issue:
When I open a class file from the project I experience issues with lots of Netbeans functionality. Syntax highlight works, syntax check, autocomplete, class import suggestion and some of other features don't. I get the following exception:

java.lang.IllegalArgumentException: version can neither be null, empty nor blank
	at org.apache.maven.artifact.ArtifactUtils.notBlank(ArtifactUtils.java:95)
	at org.apache.maven.artifact.ArtifactUtils.toSnapshotVersion(ArtifactUtils.java:53)
	at org.apache.maven.artifact.DefaultArtifact.setBaseVersionInternal(DefaultArtifact.java:354)
	at org.apache.maven.artifact.DefaultArtifact.selectVersion(DefaultArtifact.java:443)
	at org.apache.maven.artifact.DefaultArtifact.selectVersionFromNewRangeIfAvailable(DefaultArtifact.java:434)
	at org.apache.maven.artifact.DefaultArtifact.<init>(DefaultArtifact.java:126)
	at org.apache.maven.artifact.DefaultArtifact.<init>(DefaultArtifact.java:88)
	at org.netbeans.modules.maven.api.PluginPropertyUtils.getPluginPathProperty(PluginPropertyUtils.java:839)
	at org.netbeans.modules.maven.classpath.AnnotationProcClassPathImpl.getCompileArtifacts(AnnotationProcClassPathImpl.java:91)
	at org.netbeans.modules.maven.classpath.AnnotationProcClassPathImpl.createPath(AnnotationProcClassPathImpl.java:66)
	at org.netbeans.modules.maven.classpath.AbstractProjectClassPathImpl.getPath(AbstractProjectClassPathImpl.java:153)
	at org.netbeans.modules.maven.classpath.AbstractProjectClassPathImpl.getResources(AbstractProjectClassPathImpl.java:144)
	at org.netbeans.api.java.classpath.ClassPath.entries(ClassPath.java:363)
	at org.netbeans.modules.maven.classpath.ClassPathProviderImpl$AnnotationPathSelector.getActiveClassPath(ClassPathProviderImpl.java:685)
	at org.netbeans.spi.java.classpath.support.MuxClassPathImplementation.getActiveClassPath(MuxClassPathImplementation.java:156)
	at org.netbeans.spi.java.classpath.support.MuxClassPathImplementation.getResources(MuxClassPathImplementation.java:89)
	at org.netbeans.api.java.classpath.ClassPath.entries(ClassPath.java:363)
	at org.netbeans.api.java.classpath.ClassPath.getRoots(ClassPath.java:248)
	at org.netbeans.modules.java.source.indexing.APTUtils.listenOnProcessorPath(APTUtils.java:343)
	at org.netbeans.modules.java.source.indexing.APTUtils.listen(APTUtils.java:329)
	at org.netbeans.modules.java.source.indexing.APTUtils.create(APTUtils.java:234)
	at org.netbeans.modules.java.source.indexing.APTUtils.get(APTUtils.java:165)
	at org.netbeans.modules.java.source.parsing.JavacParser.createJavacTask(JavacParser.java:897)
	at org.netbeans.modules.java.source.parsing.CompilationInfoImpl.getJavacTask(CompilationInfoImpl.java:460)
	at org.netbeans.modules.java.source.parsing.CompilationInfoImpl.getJavacTask(CompilationInfoImpl.java:438)
	at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:531)
	at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:140)
	at org.netbeans.modules.parsing.impl.TaskProcessor.callGetResult(TaskProcessor.java:608)
	at org.netbeans.modules.parsing.impl.SourceCache.getResult(SourceCache.java:241)
	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:775)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:288)
	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:702)
[catch] at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:663)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1403)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2018)

Language / Project Type / NetBeans Component

Java Maven Web application project from Spring Initializr sources

How to reproduce

Please create a Spring Boot project on Spring Initializr with the following settings:
Project: Maven
Language: Java
Spring Boot: 3.3.6
Packaging: War
Java: 17
Add a single dependency for Proof of Error: Lombok.

Download the project and open it either in Netbeans 22 or 24.

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows 11

JDK

Oracle JDK 17.0.11+7-LTS-207

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

The issue is 100% reproducible every time I open a source file from the downloaded project template.

java.lang.IllegalArgumentException: version can neither be null, empty nor blank
	at org.apache.maven.artifact.ArtifactUtils.notBlank(ArtifactUtils.java:95)
	at org.apache.maven.artifact.ArtifactUtils.toSnapshotVersion(ArtifactUtils.java:53)
	at org.apache.maven.artifact.DefaultArtifact.setBaseVersionInternal(DefaultArtifact.java:354)
	at org.apache.maven.artifact.DefaultArtifact.selectVersion(DefaultArtifact.java:443)
	at org.apache.maven.artifact.DefaultArtifact.selectVersionFromNewRangeIfAvailable(DefaultArtifact.java:434)
	at org.apache.maven.artifact.DefaultArtifact.<init>(DefaultArtifact.java:126)
	at org.apache.maven.artifact.DefaultArtifact.<init>(DefaultArtifact.java:88)
	at org.netbeans.modules.maven.api.PluginPropertyUtils.getPluginPathProperty(PluginPropertyUtils.java:839)
	at org.netbeans.modules.maven.classpath.AnnotationProcClassPathImpl.getCompileArtifacts(AnnotationProcClassPathImpl.java:91)
	at org.netbeans.modules.maven.classpath.AnnotationProcClassPathImpl.createPath(AnnotationProcClassPathImpl.java:66)
	at org.netbeans.modules.maven.classpath.AbstractProjectClassPathImpl.getPath(AbstractProjectClassPathImpl.java:153)
	at org.netbeans.modules.maven.classpath.AbstractProjectClassPathImpl.getResources(AbstractProjectClassPathImpl.java:144)
	at org.netbeans.api.java.classpath.ClassPath.entries(ClassPath.java:363)
	at org.netbeans.modules.maven.classpath.ClassPathProviderImpl$AnnotationPathSelector.getActiveClassPath(ClassPathProviderImpl.java:685)
	at org.netbeans.spi.java.classpath.support.MuxClassPathImplementation.getActiveClassPath(MuxClassPathImplementation.java:156)
	at org.netbeans.spi.java.classpath.support.MuxClassPathImplementation.getResources(MuxClassPathImplementation.java:89)
	at org.netbeans.api.java.classpath.ClassPath.entries(ClassPath.java:363)
	at org.netbeans.api.java.classpath.ClassPath.getRoots(ClassPath.java:248)
	at org.netbeans.modules.java.source.indexing.APTUtils.listenOnProcessorPath(APTUtils.java:343)
	at org.netbeans.modules.java.source.indexing.APTUtils.listen(APTUtils.java:329)
	at org.netbeans.modules.java.source.indexing.APTUtils.create(APTUtils.java:234)
	at org.netbeans.modules.java.source.indexing.APTUtils.get(APTUtils.java:165)
	at org.netbeans.modules.java.source.parsing.JavacParser.createJavacTask(JavacParser.java:897)
	at org.netbeans.modules.java.source.parsing.CompilationInfoImpl.getJavacTask(CompilationInfoImpl.java:460)
	at org.netbeans.modules.java.source.parsing.CompilationInfoImpl.getJavacTask(CompilationInfoImpl.java:438)
	at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:531)
	at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:140)
	at org.netbeans.modules.parsing.impl.TaskProcessor.callGetResult(TaskProcessor.java:608)
	at org.netbeans.modules.parsing.impl.SourceCache.getResult(SourceCache.java:241)
	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:775)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:288)
	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:702)
[catch] at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:663)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1403)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2018)

Are you willing to submit a pull request?

No

@kz282 kz282 added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Dec 14, 2024
@neilcsmith-net
Copy link
Member

neilcsmith-net commented Dec 14, 2024

Add a single dependency for Proof of Error: Lombok.

Something tells me that's your problem. Make sure the version of Lombok is compatible with JDK 23 (the compiler used inside the IDE) and see if the problem goes away.

Probably a duplicate of #7664

@kz282
Copy link
Author

kz282 commented Dec 14, 2024

@neilcsmith-net neilcsmith-net added the pending-response Awaiting further information to be supplied label Dec 14, 2024
@kz282
Copy link
Author

kz282 commented Dec 14, 2024

My project is running on JDK 17 and I have not installed JDK 23.
Spring Boot 3.3.6 depends on lombok 1.18.36.
According to lombok changelog lombok v1.18.36 is supported on JDK23.

@kz282
Copy link
Author

kz282 commented Dec 14, 2024

Probably a duplicate of #8041

@neilcsmith-net
Copy link
Member

neilcsmith-net commented Dec 14, 2024

My project is running on JDK 17 and I have not installed JDK 23.

The javac compiler used inside NetBeans is from JDK 23.

I'm not sure where the Lombok version is being specified. The error might suggest that it is not being found. Make the dependency on version 1.18.36 explicit in your pom and try again.

@kz282
Copy link
Author

kz282 commented Dec 14, 2024

I have found something interesting while editing the pom.xml.
I have deleted the Netbeans cache before each try.
The lombok version does not need to be set explicitly. Spring Boot 3.3.5 depends on lombok 1.18.34, but it works the same:

<dependency>
	<groupId>org.projectlombok</groupId>
	<artifactId>lombok</artifactId>
	<optional>true</optional>
	<!--<version>1.18.36</version>-->
</dependency>

The maven-compiler-plugin configuration of the generated pom.xml breaks the IDE:

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
<!-- This configuration breaks the IDE. It is in the Spring Initializr template when Lombok is selected. No version information inside
	<configuration>
		<annotationProcessorPaths>
			<path>
				<groupId>org.projectlombok</groupId>
				<artifactId>lombok</artifactId>
			</path>
		</annotationProcessorPaths>
	</configuration> -->
</plugin>

If I specify the lombok version inside the plugin / configuration / annotationProcessorPaths / path, all IDE feature are working properly. Setting this version field to 1.18.34 works too.

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<configuration>
		<annotationProcessorPaths>
			<path>
				<groupId>org.projectlombok</groupId>
				<artifactId>lombok</artifactId>
				<version>1.18.36</version>
			</path>
		</annotationProcessorPaths>
	</configuration>
</plugin>

matthiasblaesing added a commit to matthiasblaesing/netbeans that referenced this issue Dec 14, 2024
…essors like lombok)

Resolution of processors also needs to take into account, that for
example the version for an artifact could be provided by
DependencyManagement.

Closes: apache#8054
Closes: apache#8041
@matthiasblaesing
Copy link
Contributor

The classpath resolution code is missing quering the DependencyManagment for the plugin version that is correctedin #8057. Please test the nightly build Checks page direct link.

@neilcsmith-net
Copy link
Member

Thanks @matthiasblaesing Had just started looking at that having reached the same realisation. Mention of Lombok made me just assume that was the usual issue at first! 🤷

@mbien mbien added Maven [ci] enable "build tools" tests Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) and removed needs:triage Requires attention from one of the committers labels Dec 15, 2024
matthiasblaesing added a commit to matthiasblaesing/netbeans that referenced this issue Dec 21, 2024
…essors like lombok)

Resolution of processors also needs to take into account, that for
example the version for an artifact could be provided by
DependencyManagement.

Closes: apache#8054
Closes: apache#8041
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) kind:bug Bug report or fix Maven [ci] enable "build tools" tests pending-response Awaiting further information to be supplied
Projects
None yet
4 participants