apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.61k stars 836 forks source link

NetBeans 21 ends up in broken state if you activate some IDE features via Options panel before creating a new project #7091

Closed iajn closed 2 months ago

iajn commented 5 months ago

Apache NetBeans version

Apache NetBeans 21 (not selectable in the dropdown)

What happened

On the new NetBeans IDE 21 if you end up activating some IDE features via Options panel (e.g. by selecting the Java tab, which activates Tools) the IDE ends up in a broken state. In this state trying to create e.g. a new Maven project fails after selecting the project type, you first get "Configuring java cluster" and afterwards it briefly flashes "Activating Java SE" before ending up on an empty screen with title "Finding Feature".

Creating a new project (e.g. Maven -> NetBeans Platform application) on a fresh installation before accessing any of the options menus circumvents the issue and the project is created correctly.

Once the IDE ends up in the broken state it doesn't seem possible to recover by restarting the IDE, unless you clear the caches manually first.

I'm using Windows 11, reproduced the issue using both JDK 21 (prepackaged with the community installer) and JDK 17 (JetBrains). (Side note, seemed like the community installer didn't configure the prepackaged JDK correctly, so I added the jdkhome manually to the netbeans.conf file.)

Also tried the standard installer and binary zip, same issue. Cleaned up old caches and userdirs between attempts.

On my previous NetBeans installation (20-rc1) the issue doesn't appear.

Language / Project Type / NetBeans Component

Java / Maven

How to reproduce

After fresh install on Windows 11, access Java options panel before doing anything else. Afterwards creating new Maven projects fails.

Did this work correctly in an earlier version?

Apache NetBeans 20

Operating System

Windows 11

JDK

Prepackaged JDK 21.0.2; OpenJDK 64-Bit Server VM 21.0.2+13-LTS

Apache NetBeans packaging

Apache NetBeans provided installer, Apache NetBeans binary zip, Third-party package

Anything else

Here is a log of me opening the IDE, clicking the Java tab in the options menu, trying to create a NetBeans Platform Maven project, trying to create an empty pom project, and closing the IDE. There are some repeating warnings (below) and some error after the system gives up.

WARNING [org.netbeans.modules.ide.ergonomics.newproject.DescriptionStep]: There is still wrong iterator org.netbeans.modules.ide.ergonomics.newproject.FeatureOnDemandWizardIterator for file object MultiFileObject@59784d9e[Templates/Project/Maven2/org-netbeans-modules-maven-apisupport-NbmWizardIterator-createNbAppIterator]

messages.log

Are you willing to submit a pull request?

No

neilcsmith-net commented 5 months ago

Can replicate on Ubuntu. You can use Tools / Plugins / Installed and select Java SE and Activate. Also from the Start Page, click Activate Features to get to the same place.

This is a little annoying. Ergonomics causes too many issues. Not sure what the cause is here.

(Side note, seemed like the community installer didn't configure the prepackaged JDK correctly, so I added the jdkhome manually to the netbeans.conf file.)

I assume you're not using the created shortcut? Directly running netbeans(64).exe will not work correctly.

iajn commented 5 months ago

You can use Tools / Plugins / Installed and select Java SE and Activate.

Right, this fixed the issue.

I assume you're not using the created shortcut? Directly running netbeans(64).exe will not work correctly.

Yes, my bad. I was indeed mostly using the exe directly. I did check if the shortcut sets the jdkhome flag before creating the issue, but I think I mistakenly checked it from the shortcut created by the standard installer since I tried both.

mbien commented 5 months ago

the last big change in that area was https://github.com/apache/netbeans/pull/6355 AFAIR however, since you said:

On my previous NetBeans installation (20-rc1) the issue doesn't appear.

this would indicate that this isn't the cause, since it would have been in NB 20 already at this point.

However, i remember while testing the PR above, I already saw some weird behavior in NB 19 and before: https://github.com/apache/netbeans/pull/6355#issuecomment-1758959915

mbien commented 3 months ago

found another way how to break it:

ebarboni commented 3 months ago

for NB23

neilcsmith-net commented 3 months ago

@ebarboni why? This should be checked and still open for fixing after branching if a cause is found. No need to move the milestone on any bugs at this stage.

ebarboni commented 3 months ago

if issue is found during the rc and release preparation milestone could be set to back 22 but. I try to reduce the list of item in milestone nb22 to have idea what to look at.

neilcsmith-net commented 3 months ago

Still broken on NB22-rc1, and not easy to get out of once triggered. Moving the milestone back.

neilcsmith-net commented 3 months ago

Checked that this is definitely a regression between 20 and 21, so #6355 likely not the cause. Log shows only about half of the modules activated in 21 compared to earlier.

neilcsmith-net commented 3 months ago

After far too much stepping through on the debugger I think I've narrowed down to a regression caused by #6743

At first thought was caused by the changes at https://github.com/apache/netbeans/pull/6743/commits/da719272474b35d9c736c3242f4f19fb0a529aeb#diff-5504532548e9970b0fdf2f4436defb1b53d234a604b1c0872466db36139ab685R134

Ergonomics ignores the returned restarter, which is why the Maven tab / wizard loops and the modules never enable (another issue!). However, forcing the load breaks because libs.nbjavacapi cannot be loaded due to the fragment host already being enabled.

As far as I can tell, the Options / Java / Ant panel causes ergonomics to enable the extide cluster, but also a few modules from the java cluster including java.source.base. This triggers libs.javacapi to load without libs.nbjavacapi. Attempting to open the Maven tab in the Java cluster then fails because libs.nbjavacapi cannot be loaded.

Simplest fix seems to be to add back OpenIDE-Module-Recommends: org.netbeans.libs.nbjavac into java.source.base. That might negate the purpose of #6743. cc/ @jlahoda @lahodaj

mbien commented 2 months ago

tested with NB22-rc2: