netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Cannot open project with an unexpected exception

Open AndrewChou77 opened this issue 1 year ago • 18 comments

Apache NetBeans version

Apache NetBeans 20

What happened

When I clicked on File -> Open Project, no window poped up but with an unexpected exception appeared below. 屏幕截图 2024-02-13 214153 屏幕截图 2024-02-13 214210 屏幕截图 2024-02-13 214238 I have tried different version of JDK and clear the cache of previous Netbeans but none of them worked.

Language / Project Type / NetBeans Component

No response

How to reproduce

I'm not sure just click File then Open Project

Did this work correctly in an earlier version?

No / Don't know

Operating System

windows

JDK

21

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

No

AndrewChou77 avatar Feb 14 '24 02:02 AndrewChou77

can you post the exception as text? (then mark the text and press the code button on the markdown editor)

mbien avatar Feb 14 '24 12:02 mbien

Sure thing. The general error message is like: Cannot invoke "String.matches(String)" because the return value of "java.io.File.toString()" is null. And the exceptions detail is like:

java.lang.NullPointerException: Cannot invoke "String.matches(String)" because the return value of "java.io.File.toString()" is null
	at org.netbeans.modules.project.ui.ProjectChooserAccessory$ProjectFileView.getIcon(ProjectChooserAccessory.java:578)
	at java.desktop/javax.swing.JFileChooser.getIcon(JFileChooser.java:1607)
	at org.netbeans.swing.dirchooser.DirectoryChooserUI$DirectoryComboBoxRenderer.getListCellRendererComponent(DirectoryChooserUI.java:1858)
	at java.desktop/javax.swing.plaf.basic.BasicComboBoxUI.getDisplaySize(BasicComboBoxUI.java:1446)
	at com.formdev.flatlaf.ui.FlatComboBoxUI.getDisplaySize(FlatComboBoxUI.java:711)
	at java.desktop/javax.swing.plaf.basic.BasicComboBoxUI.getMinimumSize(BasicComboBoxUI.java:999)
	at com.formdev.flatlaf.ui.FlatComboBoxUI.getMinimumSize(FlatComboBoxUI.java:694)
	at java.desktop/javax.swing.plaf.basic.BasicComboBoxUI.getPreferredSize(BasicComboBoxUI.java:988)
	at java.desktop/javax.swing.JComponent.getPreferredSize(JComponent.java:1734)
	at org.netbeans.swing.dirchooser.DirectoryChooserUI$7.getPreferredSize(DirectoryChooserUI.java:566)
	at java.desktop/java.awt.BorderLayout.preferredLayoutSize(BorderLayout.java:724)
	at java.desktop/java.awt.Container.preferredSize(Container.java:1826)
	at java.desktop/java.awt.Container.getPreferredSize(Container.java:1810)
	at java.desktop/javax.swing.JComponent.getPreferredSize(JComponent.java:1736)
	at java.desktop/java.awt.BorderLayout.preferredLayoutSize(BorderLayout.java:724)
	at java.desktop/java.awt.Container.preferredSize(Container.java:1826)
	at java.desktop/java.awt.Container.getPreferredSize(Container.java:1810)
	at java.desktop/javax.swing.JComponent.getPreferredSize(JComponent.java:1736)
	at java.desktop/java.awt.BorderLayout.layoutContainer(BorderLayout.java:820)
	at java.desktop/java.awt.Container.layout(Container.java:1541)
	at java.desktop/java.awt.Container.doLayout(Container.java:1530)
	at java.desktop/java.awt.Container.validateTree(Container.java:1725)
	at java.desktop/java.awt.Container.validateTree(Container.java:1734)
	at java.desktop/java.awt.Container.validateTree(Container.java:1734)
	at java.desktop/java.awt.Container.validateTree(Container.java:1734)
	at java.desktop/java.awt.Container.validateTree(Container.java:1734)
	at java.desktop/java.awt.Container.validateTree(Container.java:1734)
	at java.desktop/java.awt.Container.validateTree(Container.java:1734)
	at java.desktop/java.awt.Container.validate(Container.java:1660)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2778)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4828)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:775)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:98)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:747)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:744)
	at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:136)
[catch] at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

AndrewChou77 avatar Feb 14 '24 18:02 AndrewChou77

can you post the exception as text? (then mark the text and press the code button on the markdown editor)

I have posted the exception and the exception detail as a text. And BTW what do you mean by mark the text and press the code button on the markdown editor?

AndrewChou77 avatar Feb 14 '24 18:02 AndrewChou77

Could you be more specific about exactly what JDK you're using?

How can File::toString be null?!

And BTW what do you mean by mark the text and press the code button on the markdown editor?

The <> button in the comment editor here - I've done it for you.

neilcsmith-net avatar Feb 14 '24 18:02 neilcsmith-net

I'm using JDK 21.0.2

AndrewChou77 avatar Feb 14 '24 18:02 AndrewChou77

Could you be more specific about exactly what JDK you're using?

How can File::toString be null?!

And BTW what do you mean by mark the text and press the code button on the markdown editor?

The <> button in the comment editor here - I've done it for you.

I don't know actually. It's really weird.

AndrewChou77 avatar Feb 14 '24 18:02 AndrewChou77

Could you be more specific about exactly what JDK you're using?

How can File::toString be null?!

And BTW what do you mean by mark the text and press the code button on the markdown editor?

The <> button in the comment editor here - I've done it for you.

image

AndrewChou77 avatar Feb 14 '24 18:02 AndrewChou77

Are there any solution for my weird problem?

AndrewChou77 avatar Feb 15 '24 22:02 AndrewChou77

This might be related to #6948. Please try to use JDK 17 or NB 21-rc3 (https://github.com/apache/netbeans/discussions/6962)

junichi11 avatar Feb 15 '24 23:02 junichi11

Just to save anyone else the effort, the last Netbeans code before the exception is (line 578) in https://github.com/apache/netbeans/blob/6a9d501fd805541ed261fd371772ab772c294c7f/ide/projectui/src/org/netbeans/modules/project/ui/ProjectChooserAccessory.java#L566-L599

I can't see how a File could return null from toString either - it just returns the string path (same as getPath) so someone would have had to construct a File with a null path.

Is is possible Open Project is defaulting to start from a directory that no longer exists or is invalid in some way? Is it possible to reset that starting directory somehow (where is it stored?)

pedro-w avatar Feb 16 '24 11:02 pedro-w

This might be related to #6948. Please try to use JDK 17 or NB 21-rc3 (#6962) I tried but it didn't work.

AndrewChou77 avatar Feb 16 '24 19:02 AndrewChou77

Just to save anyone else the effort, the last Netbeans code before the exception is (line 578) in

https://github.com/apache/netbeans/blob/6a9d501fd805541ed261fd371772ab772c294c7f/ide/projectui/src/org/netbeans/modules/project/ui/ProjectChooserAccessory.java#L566-L599

I can't see how a File could return null from toString either - it just returns the string path (same as getPath) so someone would have had to construct a File with a null path.

Is is possible Open Project is defaulting to start from a directory that no longer exists or is invalid in some way? Is it possible to reset that starting directory somehow (where is it stored?)

No I don't think so, I can't such settings in netbeans.

AndrewChou77 avatar Feb 16 '24 19:02 AndrewChou77

No I don't think so, I can't such settings in netbeans.

Can you check though? Look in your 'User directory' (you can see what this is in the About dialog) under config/Preferences/org/netbeans/modules/projectui.properties and see if anything looks weird there. For you, I guess it will be C:\Users\Andrew Chou\AppData\Roaming\Netbeans\20\config\Preferences\org\netbeans\modules\projectui.properties

Other questions:

  • Have you ever managed to open a project with this version of NB or has it always given this error?
  • Can you open a file or does that also not work?
  • Have you tried uninstalling NB and re-installing? (if it asks to import settings from a previous installation, say no, to give you a clean start)

Hopefully something will begin to make sense!

pedro-w avatar Feb 17 '24 18:02 pedro-w

No I don't think so, I can't such settings in netbeans.

Can you check though? Look in your 'User directory' (you can see what this is in the About dialog) under config/Preferences/org/netbeans/modules/projectui.properties and see if anything looks weird there. For you, I guess it will be C:\Users\Andrew Chou\AppData\Roaming\Netbeans\20\config\Preferences\org\netbeans\modules\projectui.properties

Other questions:

  • Have you ever managed to open a project with this version of NB or has it always given this error?
  • Can you open a file or does that also not work?
  • Have you tried uninstalling NB and re-installing? (if it asks to import settings from a previous installation, say no, to give you a clean start)

Hopefully something will begin to make sense!

屏幕截图 2024-02-17 142122 屏幕截图 2024-02-17 142435

Thank you for your patience and help! But I don't think I have the file named projectui.properties you're talking about in my folder. Just a file named ui.properties. And for your other questions, when I used netbeans the year before last, everything was fine. Last month, I needed to start using Netbeans again because of a certain project and it didn't work properly when I opened the project. But open file can work properly. Yes, I have tried uninstalling the NB and tried a lot different versions of NB. Everytime before my installation, I will clean the previous one's cache. But they all showed the same problem that can't open project.

AndrewChou77 avatar Feb 17 '24 19:02 AndrewChou77

I don't really have any more ideas - hopefully someone else has some thoughts?

The only thing was that you looked in C:\Users\Andrew Chou\AppData\Roaming\NetBeans\19\config\Preferences and as you appear to be using NetBeans 20, the files should be in C:\Users\Andrew Chou\AppData\Roaming\NetBeans\20\config\Preferences

Was there nothing under the \20\ subdirectory? That might be significant.

pedro-w avatar Feb 19 '24 09:02 pedro-w

If that config file doesn't exist then it should still be the default NetBeansProjects folder that the open project dialog is trying to access. Look for that folder. Does it exist, and does it have projects in it? Try renaming the folder and seeing if the project dialog will open. If that fixes it, try copying things across until you find whether there is a particular file that the JDK is breaking with.

neilcsmith-net avatar Feb 19 '24 09:02 neilcsmith-net

I don't really have any more ideas - hopefully someone else has some thoughts?

The only thing was that you looked in C:\Users\Andrew Chou\AppData\Roaming\NetBeans\19\config\Preferences and as you appear to be using NetBeans 20, the files should be in C:\Users\Andrew Chou\AppData\Roaming\NetBeans\20\config\Preferences

Was there nothing under the *\20* subdirectory? That might be significant.

There's only a org folder inside C:\Users\Andrew Chou\AppData\Roaming\NetBeans\20\config\Preferences

AndrewChou77 avatar Feb 20 '24 02:02 AndrewChou77

If that config file doesn't exist then it should still be the default NetBeansProjects folder that the open project dialog is trying to access. Look for that folder. Does it exist, and does it have projects in it? Try renaming the folder and seeing if the project dialog will open. If that fixes it, try copying things across until you find whether there is a particular file that the JDK is breaking with.

Yes, the NetBeansProjects folder does exists and has projects in it. I tried rename it and it didn't work.

AndrewChou77 avatar Feb 20 '24 02:02 AndrewChou77