This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 13038 - Palette bean containing label with classpath icon throws NullPointerException
Summary: Palette bean containing label with classpath icon throws NullPointerException
Status: CLOSED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 3.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jesse Glick
URL:
Keywords:
: 18208 18719 19534 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-06-20 18:01 UTC by Robert Baruch
Modified: 2008-12-22 15:51 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
NullPointerException (2.77 KB, text/plain)
2001-06-21 09:26 UTC, Marian Mirilovic
Details
sample form - java (1.45 KB, text/plain)
2001-11-06 17:03 UTC, Tomas Pavek
Details
sample form - form file (2.22 KB, text/plain)
2001-11-06 17:05 UTC, Tomas Pavek
Details
Stack trace showing why customizing a frame is not necessarily possible (2.02 KB, text/plain)
2001-11-16 11:27 UTC, Jesse Glick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Baruch 2001-06-20 18:01:57 UTC
To reproduce:

Add a new JFrame to the project.
Add a new JPanel to the project.
Mount a filesystem to the project which contains a small .gif file to be used as
an icon. Anything will do.

Using the form editor, add a label to the JPanel. Change the label's icon
property via the IconEditor (hit the "..." button in the property value). In the
icon editor, select Classpath, and browse to the .gif file you placed in the
filesystem. Hit the OK button when you're done, and the panel will have a label
with the icon to its left. Save and compile.

In the Explorer, right-click on the panel class, select Tools > Add to Component
Palette..., and add it to the Beans category.

Using the form editor, open the JFrame. Select the new panel from the Beans
component and attempt to add it to the JFrame. 

What is expected:

The component should be added to the JFrame.

What happens:

A NullPointerException is thrown. Note that if we now go back to the JPanel,
remove the icon, save, recompile, delete the bean from the palette, and add it
again, and then we try to add the new panel to the JFrame, the panel is added
successfully. Therefore, the presence of the icon causes the
NullPointerException to be thrown.
Comment 1 Marian Mirilovic 2001-06-21 09:25:10 UTC
It's serious bug.
dialog : "The Component cannot be instantiated java.lang.NulllPointerException"
NPE(attachment)

Comment 2 Marian Mirilovic 2001-06-21 09:26:17 UTC
Created attachment 1659 [details]
NullPointerException
Comment 3 Tomas Pavek 2001-11-06 17:03:31 UTC
Created attachment 3283 [details]
sample form - java
Comment 4 Tomas Pavek 2001-11-06 17:05:14 UTC
Created attachment 3284 [details]
sample form - form file
Comment 5 Tomas Pavek 2001-11-06 17:21:43 UTC
This issue is not related to form editor, it's some ClassLoader 
problem - reassigning to core. I have no idea what could be wrong...

Look at the form sample in attachment (place it in the sampledir 
directory). There's the following code:

jLabel1.setIcon(new javax.swing.ImageIcon(
  getClass().getResource("/examples/colorpicker/ColorPreview.gif")));

The form can be executed externaly or internally and the icon 
resource is found. However, trying to invoke "Customize Bean" on the 
form in the IDE (from Explorer) fails - because the resource is not 
found (this causes the NPE reported above). Note that the class and 
the icon are in the same filesystem...

This problem occurs also in 3.2.1 and current dev builds (20011102).
Comment 6 Jan Zajicek 2001-11-07 13:10:15 UTC
Davide, can you look at this one? Thanks.
Comment 7 David Strupl 2001-11-08 17:12:09 UTC
Jesse can you please check this one? Or if you know who would know
please reassign accordingly. Thanks.
Comment 8 Jesse Glick 2001-11-08 18:34:46 UTC
It's a security exception.

java.security.AccessControlException: access denied
(java.net.NetPermission specifyStreamHandler)
	at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:272)
	at
java.security.AccessController.checkPermission(AccessController.java:399)
	at
java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
	at
org.netbeans.core.execution.TopSecurityManager.checkPermission(TopSecurityManager.java:255)
	at java.net.URL.checkSpecifyHandler(URL.java:527)
	at java.net.URL.<init>(URL.java:289)
	at org.openide.filesystems.FileURL.encodeFileObject(FileURL.java:82)
	at org.openide.filesystems.FileURL.encodeFileObject(FileURL.java:69)
	at org.openide.filesystems.FileObject.getURL(FileObject.java:568)
	at
org.openide.execution.NbfsURLConnection.connect(NbfsURLConnection.java:103)
	at
org.openide.execution.NbfsURLConnection.getHeaderField(NbfsURLConnection.java:146)
	at java.net.URLConnection.getContentType(URLConnection.java:377)
	at Fr2.<init>(Fr2.java:23)
	at java.lang.Class.newInstance0(Native Method)
	at java.lang.Class.newInstance(Class.java:237)
	at
org.openide.loaders.InstanceSupport.instanceCreate(InstanceSupport.java:203)
[catch] at
org.openide.actions.CustomizeBeanAction.customize(CustomizeBeanAction.java:131)

Now I need to figure out what FileURL is trying to do and why it needs
to set an explicit stream handler when nbfs: is normally registered
anyway.
Comment 9 Jesse Glick 2001-11-14 15:00:01 UTC
OK, I have a patch, will commit tomorrow.

Robert, I don't see any great workaround for 3.2.1 (will be fixed for
3.3). However there is a workaround which ought to be enough: start
the IDE with the option:

-J-Dnetbeans.security.nocheck=true

If you do this, be *careful* as the IDE will turn off all internal
Java security checks. In practice this means that if you are using the
internal ICE browser, don't view any applets you didn't write and
trust. Nor should you "Customize Bean" on any class you didn't write.
Comment 10 Jesse Glick 2001-11-15 11:40:11 UTC
committed     Up-To-Date  1.6        
openide/src/org/openide/filesystems/FileURL.java
Comment 11 Tomas Pavek 2001-11-16 10:46:43 UTC
I still see the same problem in 20011116...
It works using -J-Dnetbeans.security.nocheck=true.
Comment 12 Jesse Glick 2001-11-16 11:26:07 UTC
This is very odd. I tried the original test case when fixing the bug
and it worked fine. Now all my test cases used when fixing it no
longer work. No security exception appears, and the raw nbfs: URLs
work fine, but ClassLoader.getResource for some reason still returns
null. (Note that it tries to connect to URLs and quietly swallows any
exceptions it encounters, making debugging lots of fun.)

Tomas your test case is not useful--you cannot customize a JFrame, as
the pack() call in the constructor involves protected calls which will
not work from a user-mode class (see attachment). Robert's test case
with a JPanel is useful.
Comment 13 Jesse Glick 2001-11-16 11:27:31 UTC
Created attachment 3447 [details]
Stack trace showing why customizing a frame is not necessarily possible
Comment 14 Tomas Pavek 2001-11-16 12:57:38 UTC
I see. Sorry for providing bad example (JPanel should be used 
instead)...

> (Note that it tries to connect to URLs and quietly swallows any
> exceptions it encounters, making debugging lots of fun.)
Yes, I also tried to debug it first but gave up...
Comment 15 Jesse Glick 2001-11-17 09:05:54 UTC
I am still not exactly sure what enabled my earlier test case to
succeed, but anyway more needed to be done. Actually getting a URL
from Class.getResource() requires URLClassPath to like your
URLConnection.permission, which the nbfs: connection did not
specifically provide, thus it was the default AllPermission, which the
user-mode class definitely cannot get. File read permissions are all
that are really needed for making an nbfs: connection; in principle
user-mode classes would have difficulty with that too, however in fact
TopSecurityManager gives unconditional file read permission anyway
(for performance reasons), so this succeeds.

committed   * Up-To-Date  1.17       
openide/src/org/openide/execution/NbfsURLConnection.java
committed   * Up-To-Date  1.7        
openide/src/org/openide/filesystems/FileURL.java

and a test for NbClassLoader added.
Comment 16 Marian Mirilovic 2001-11-30 08:34:35 UTC
*** Issue 18208 has been marked as a duplicate of this issue. ***
Comment 17 Tomas Pavek 2002-01-02 13:55:24 UTC
*** Issue 18719 has been marked as a duplicate of this issue. ***
Comment 18 Tomas Pavek 2002-01-22 16:41:26 UTC
*** Issue 19534 has been marked as a duplicate of this issue. ***
Comment 19 Tomas Pavek 2002-02-11 16:56:37 UTC
*** Issue 19534 has been marked as a duplicate of this issue. ***
Comment 20 pzajac 2003-06-11 14:52:34 UTC
veryfied.
Comment 21 Quality Engineering 2003-07-01 16:37:58 UTC
Resolved for 3.4.x or earlier, no new info since then -> closing.