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 198992 - NullPointerException at org.netbeans.modules.j2ee.sun.ide.sunresources.resourcesloader.SunResourceDataObject.getResource
Summary: NullPointerException at org.netbeans.modules.j2ee.sun.ide.sunresources.resour...
Status: VERIFIED FIXED
Alias: None
Product: serverplugins
Classification: Unclassified
Component: GlassFish (show other bugs)
Version: 7.0
Hardware: All All
: P1 normal with 1 vote (vote)
Assignee: TomasKraus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-30 09:39 UTC by Petr Cyhelsky
Modified: 2013-07-10 11:43 UTC (History)
19 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 179078


Attachments
stacktrace (1.85 KB, text/plain)
2011-05-30 09:39 UTC, Petr Cyhelsky
Details
stacktrace (1.85 KB, text/plain)
2011-06-01 10:23 UTC, Petr Cyhelsky
Details
stacktrace (1.86 KB, text/plain)
2011-10-10 15:38 UTC, Kenneth Ganfield
Details
stacktrace (1.86 KB, text/plain)
2011-11-11 10:25 UTC, Kenneth Ganfield
Details
stacktrace (1.84 KB, text/plain)
2012-09-07 14:58 UTC, Lukas Jungmann
Details
stacktrace (2.06 KB, text/plain)
2012-11-30 21:20 UTC, everflux
Details
stacktrace (1.84 KB, text/plain)
2013-06-19 11:37 UTC, davidsalter
Details
stacktrace (1.84 KB, text/plain)
2013-07-06 20:02 UTC, janario
Details
stacktrace (1.84 KB, text/plain)
2013-07-06 20:05 UTC, janario
Details
Simple fix to avoid NPE in SunResourceDataObject.java:191 (from stack traces). (876 bytes, patch)
2013-07-08 10:33 UTC, TomasKraus
Details | Diff
NPE safe test for all resource arrays in method. (3.95 KB, patch)
2013-07-08 10:34 UTC, TomasKraus
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Cyhelsky 2011-05-30 09:39:38 UTC
Build: NetBeans IDE 7.0.1 Dev (Build 201105190000)
VM: Java HotSpot(TM) 64-Bit Server VM, 20.0-b11, Java(TM) SE Runtime Environment, 1.6.0_25-b06
OS: Linux

User Comments:
cyhelsky: on find




Stacktrace: 
java.lang.NullPointerException
   at org.netbeans.modules.j2ee.sun.ide.sunresources.resourcesloader.SunResourceDataObject.getResource(SunResourceDataObject.java:188)
   at org.netbeans.modules.j2ee.sun.ide.sunresources.resourcesloader.SunResourceDataObject.<init>(SunResourceDataObject.java:120)
   at org.netbeans.modules.j2ee.sun.ide.sunresources.resourcesloader.SunResourceDataLoader.createMultiObject(SunResourceDataLoader.java:87)
   at org.openide.loaders.MultiFileLoader.handleFindDataObject(MultiFileLoader.java:145)
   at org.openide.loaders.DataObjectPool.handleFindDataObject(DataObjectPool.java:161)
   at org.openide.loaders.DataLoader.findDataObject(DataLoader.java:407)
Comment 1 Petr Cyhelsky 2011-05-30 09:39:42 UTC
Created attachment 108588 [details]
stacktrace
Comment 2 Petr Cyhelsky 2011-06-01 10:23:57 UTC
Created attachment 108651 [details]
stacktrace

after invoking find on multiple project nodes
Comment 3 Vince Kraemer 2011-06-01 17:15:37 UTC
Do not know why I am getting called with a null FileObject, prevent the NPE by detecting the null and forcing the caller (who should not be asking for the DataObject of a null FileObject) deal with it via an IOException.
Comment 4 Quality Engineering 2011-06-02 20:11:22 UTC
Integrated into 'main-golden', will be available in build *201106021001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/a283626238cf
User: Vince Kraemer <vkraemer@netbeans.org>
Log: #198992 : null FileObject causes NPE... probably should not get a null FileObject
Comment 5 Vince Kraemer 2011-06-02 23:10:09 UTC
in the dev build
Comment 6 Petr Cyhelsky 2011-10-04 13:01:07 UTC
Still happens in:

Product Version: NetBeans IDE Dev (Build 201110020601)
Java: 1.7.0; Java HotSpot(TM) 64-Bit Server VM 21.0-b18
System: Linux version 2.6.38-11-generic running on amd64; UTF-8; en_US (nb)

Steps to reproduce:
Have multiple netbeans projects open -> select some of them -> invoke find from popup menu -> try to find something in the selection -> exception pops
Comment 7 Kenneth Ganfield 2011-10-10 15:38:13 UTC
Created attachment 111794 [details]
stacktrace

searching repository
Comment 8 Kenneth Ganfield 2011-11-11 10:25:25 UTC
Created attachment 113112 [details]
stacktrace

searching in hg repository
Comment 9 Exceptions Reporter 2012-01-07 21:44:24 UTC
This bug already has 20 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=179078
Comment 10 Lukas Jungmann 2012-09-07 14:58:59 UTC
Created attachment 124038 [details]
stacktrace

doing Find on Files
Comment 11 everflux 2012-11-30 21:20:33 UTC
Created attachment 128680 [details]
stacktrace

Opening netbeans modules in Netbeans nightly
Comment 12 davidsalter 2013-06-19 11:37:57 UTC
Created attachment 136022 [details]
stacktrace

Searching through the NetBeans source code and this error occurred.
Comment 13 janario 2013-07-06 20:02:37 UTC
Created attachment 136763 [details]
stacktrace

.
Comment 14 janario 2013-07-06 20:05:37 UTC
Created attachment 136764 [details]
stacktrace

.
Comment 15 Exceptions Reporter 2013-07-06 20:05:42 UTC
This bug already has 50 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=179078
Comment 16 TomasKraus 2013-07-08 10:05:55 UTC
http://statistics.netbeans.org/exceptions/exception.do?id=679972 and other reports points to SunResourceDataObject.java:191:

    JdbcConnectionPool[] pools = resources.getJdbcConnectionPool();
    if(pools.length != 0){
        ConnPoolBean currCPBean = ConnPoolBean.createBean(pools[0]);
        type = this.JDBC_CP;
        setPool(currCPBean);
    }  

It looks like pools value can be null and this is causing NPE.

Changing condition to

    if(pools != null && pools.length > 0){


Checked into web-main:
----------------------
changeset:   255036:d17c21d51d68
summary:     #198992 - NullPointerException at org.netbeans.modules.j2ee.sun.ide.sunresources.resourcesloader.SunResourceDataObject.getResource

I can't push it now because I'm currently working on large set of changes. But fix can be transplanted into 7.4 beta branch when needed.
Comment 17 TomasKraus 2013-07-08 10:25:58 UTC
Checked into web-main:
----------------------
changeset:   255037:2d26c1caa59d
summary:     #198992 - Safe tests for all resources

Added NPE safe tests for all pool arrays.

I just don't understand one thing. All those if statements are inside try / catch (NullPointerException npe) block. So why NPE is thrown outside of this block?
Comment 18 Tomas Danek 2013-07-08 10:32:31 UTC
Tomas, please notice that QE *will not test* test fix unless it is in trunk. (Only fix verified by QE can be transplanted to beta branch).  

(In reply to comment #16)
> http://statistics.netbeans.org/exceptions/exception.do?id=679972 and other
> reports points to SunResourceDataObject.java:191:
> 
>     JdbcConnectionPool[] pools = resources.getJdbcConnectionPool();
>     if(pools.length != 0){
>         ConnPoolBean currCPBean = ConnPoolBean.createBean(pools[0]);
>         type = this.JDBC_CP;
>         setPool(currCPBean);
>     }  
> 
> It looks like pools value can be null and this is causing NPE.
> 
> Changing condition to
> 
>     if(pools != null && pools.length > 0){
> 
> 
> Checked into web-main:
> ----------------------
> changeset:   255036:d17c21d51d68
> summary:     #198992 - NullPointerException at
> org.netbeans.modules.j2ee.sun.ide.sunresources.resourcesloader.SunResourceDataObject.getResource
> 
> I can't push it now because I'm currently working on large set of changes. But
> fix can be transplanted into 7.4 beta branch when needed.
Comment 19 TomasKraus 2013-07-08 10:33:29 UTC
Created attachment 136812 [details]
Simple fix to avoid NPE in SunResourceDataObject.java:191 (from stack traces).
Comment 20 TomasKraus 2013-07-08 10:34:25 UTC
Created attachment 136813 [details]
NPE safe test for all resource arrays in method.
Comment 21 TomasKraus 2013-07-08 10:41:25 UTC
Well, I'll push unfinished changes. Fortunately those changes are in GF tooling
library (code shared by NB and Eclipse) which are not integrated into NB yet so
this code is not used in GF plugin yet.
Comment 22 Stepan Zebra 2013-07-09 11:00:24 UTC
Fix verified in trunk, please integrate it into release74_beta1 branch.
Comment 23 David Strupl 2013-07-09 13:49:15 UTC
Transplanted to branch release74_beta1 as
http://hg.netbeans.org/releases/rev/4a3ce52ef83b
http://hg.netbeans.org/releases/rev/0524c29e4342
Comment 24 Quality Engineering 2013-07-10 02:43:25 UTC
Integrated into 'releases/release74_beta1', will be available in build *201307092200* or newer. Wait for official and publicly available build.

Changeset: http://hg.netbeans.org/releases/rev/4a3ce52ef83b
User: Tomas Kraus <TomasKraus@netbeans.org>
Log: #198992 - NullPointerException at org.netbeans.modules.j2ee.sun.ide.sunresources.resourcesloader.SunResourceDataObject.getResource
Comment 25 Quality Engineering 2013-07-10 04:42:13 UTC
Integrated into 'main-silver', will be available in build *201307100049* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/d17c21d51d68
User: Tomas Kraus <TomasKraus@netbeans.org>
Log: #198992 - NullPointerException at org.netbeans.modules.j2ee.sun.ide.sunresources.resourcesloader.SunResourceDataObject.getResource
Comment 26 Stepan Zebra 2013-07-10 11:43:17 UTC
(In reply to comment #24)
> Integrated into 'releases/release74_beta1', will be available in build
> *201307092200* or newer. Wait for official and publicly available build.
> 
> Changeset: http://hg.netbeans.org/releases/rev/4a3ce52ef83b
> User: Tomas Kraus <TomasKraus@netbeans.org>
> Log: #198992 - NullPointerException at
> org.netbeans.modules.j2ee.sun.ide.sunresources.resourcesloader.SunResourceDataObject.getResource

verified