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

Cannot open project with an unexpected exception #7067

Open
AndrewChou77 opened this issue Feb 14, 2024 · 18 comments
Open

Cannot open project with an unexpected exception #7067

AndrewChou77 opened this issue Feb 14, 2024 · 18 comments
Labels
kind:bug Bug report or fix os:windows UI User Interface

Comments

@AndrewChou77
Copy link

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 AndrewChou77 added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Feb 14, 2024
@mbien
Copy link
Member

mbien commented Feb 14, 2024

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

@mbien mbien added UI User Interface os:windows labels Feb 14, 2024
@AndrewChou77
Copy link
Author

AndrewChou77 commented Feb 14, 2024

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
Copy link
Author

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?

@neilcsmith-net
Copy link
Member

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.

@AndrewChou77
Copy link
Author

I'm using JDK 21.0.2

@AndrewChou77
Copy link
Author

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
Copy link
Author

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
Copy link
Author

Are there any solution for my weird problem?

@junichi11
Copy link
Member

This might be related to #6948.
Please try to use JDK 17 or NB 21-rc3 (#6962)

@mbien mbien removed the needs:triage Requires attention from one of the committers label Feb 16, 2024
@pedro-w
Copy link
Contributor

pedro-w commented Feb 16, 2024

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

public Icon getIcon(File f) {
if(f == null) {
// avoid NPE issue #268498
return null;
}
synchronized (this) { //#233480 to reduce number of calls to IO layer
Icon icon = knownProjectIcons.get(f);
if (icon != null) {
return icon;
}
}
if (
!f.toString().matches("/[^/]+") && // Unix: /net, /proc, etc.
f.getParentFile() != null) { // #173958: do not call ProjectManager.isProject now, could block
synchronized (this) {
if (lookingForIcon == null) {
lookingForIcon = f;
task.schedule(20);
// Only calculate one at a time.
// When the view refreshes, the next unknown icon
// should trigger the task to be reloaded.
}
}
}
try {
return chooser.getFileSystemView().getSystemIcon(f);
} catch (NullPointerException ex) {
//#159646: Workaround for JDK issue #6357445
// Can happen when a file was deleted on disk while project
// dialog was still open. In that case, throws an exception
// repeatedly from FSV.gSI during repaint.
return null;
}
}

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?)

@AndrewChou77
Copy link
Author

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
Copy link
Author

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

public Icon getIcon(File f) {
if(f == null) {
// avoid NPE issue #268498
return null;
}
synchronized (this) { //#233480 to reduce number of calls to IO layer
Icon icon = knownProjectIcons.get(f);
if (icon != null) {
return icon;
}
}
if (
!f.toString().matches("/[^/]+") && // Unix: /net, /proc, etc.
f.getParentFile() != null) { // #173958: do not call ProjectManager.isProject now, could block
synchronized (this) {
if (lookingForIcon == null) {
lookingForIcon = f;
task.schedule(20);
// Only calculate one at a time.
// When the view refreshes, the next unknown icon
// should trigger the task to be reloaded.
}
}
}
try {
return chooser.getFileSystemView().getSystemIcon(f);
} catch (NullPointerException ex) {
//#159646: Workaround for JDK issue #6357445
// Can happen when a file was deleted on disk while project
// dialog was still open. In that case, throws an exception
// repeatedly from FSV.gSI during repaint.
return null;
}
}

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.

@pedro-w
Copy link
Contributor

pedro-w commented Feb 17, 2024

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!

@AndrewChou77
Copy link
Author

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.

@pedro-w
Copy link
Contributor

pedro-w commented Feb 19, 2024

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.

@neilcsmith-net
Copy link
Member

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.

@AndrewChou77
Copy link
Author

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Bug report or fix os:windows UI User Interface
Projects
None yet
Development

No branches or pull requests

5 participants