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 235059

Summary: NullPointerException at org.netbeans.modules.j2ee.persistence.wizard.library.PersistenceLibrarySupport.getLibrary
Product: javaee Reporter: David Konecny <dkonecny>
Component: PersistenceAssignee: Sergey Petrov <sj-nb>
Status: RESOLVED FIXED    
Severity: normal CC: markiewb, pjiricka, sj-nb
Priority: P2 Keywords: 7.4_HR_FIX
Version: 7.4   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter: 203119
Attachments: stacktrace
stacktrace

Description David Konecny 2013-08-27 00:37:27 UTC
Build: NetBeans IDE Dev (Build 20130826-501a1632d983)
VM: Java HotSpot(TM) 64-Bit Server VM, 23.25-b01, Java(TM) SE Runtime Environment, 1.7.0_25-b15
OS: Linux

User Comments:
dkonecny: happen after "Finish"ing wizard "Entity from DB"

GUEST: create entity classes wizard gives nullpointer exception in everyday usage




Stacktrace: 
java.lang.NullPointerException
   at org.netbeans.modules.j2ee.persistence.wizard.library.PersistenceLibrarySupport.getLibrary(PersistenceLibrarySupport.java:288)
   at org.netbeans.modules.j2ee.persistence.wizard.Util.buildPersistenceUnitUsingData(Util.java:462)
   at org.netbeans.modules.j2ee.persistence.wizard.Util.buildPersistenceUnitUsingData(Util.java:432)
   at org.netbeans.modules.j2ee.persistence.wizard.fromdb.RelatedCMPWizard.instantiate(RelatedCMPWizard.java:276)
   at org.openide.loaders.TemplateWizard.handleInstantiate(TemplateWizard.java:605)
   at org.openide.loaders.TemplateWizard.instantiateNewObjects(TemplateWizard.java:439)
Comment 1 David Konecny 2013-08-27 00:37:29 UTC
Created attachment 139277 [details]
stacktrace
Comment 2 Sergey Petrov 2013-08-27 17:11:10 UTC
do you have any persistence libraries registered and or server, project type, steps?
Comment 3 David Konecny 2013-08-27 19:38:52 UTC
I cannot remember. The bug was random because running the same wizard second time passed without problems.
Comment 4 Sergey Petrov 2013-08-28 11:38:32 UTC
*** Bug 235060 has been marked as a duplicate of this bug. ***
Comment 5 Sergey Petrov 2013-09-06 11:20:00 UTC
Please use exception reporter or attach message.log. Latest build contain some logging to help to find out what may be the problem.
Comment 6 Sergey Petrov 2013-09-06 20:51:43 UTC
From two reports here and two from netcat, all 4 cases are for 64 bit environment, it may matter. But at least once it's random (on linux).

I may need to find 64 bit windows installation.
Comment 7 Sergey Petrov 2013-09-06 21:13:44 UTC
Created attachment 139780 [details]
stacktrace

new j2se project, tried entity from db
Comment 8 Sergey Petrov 2013-09-06 21:14:00 UTC
ok, for me it's  now always reproducible with j2se projects. if anybody have any other use case, please comment.
there is a workaround - create persistence.xml first, but I suppose it's as a stopper for 7.4
Comment 9 Sergey Petrov 2013-09-06 22:05:55 UTC
#233726 regression.

fix justification. before 233726  fix, if there was no provider supplier, default provider return nothing but later libraries providers was added, now need to move libraries providers into default supplier to  get old behavior and fix 235059. the fix just restore old behavior but some code is located in another place now.
http://hg.netbeans.org/web-main/rev/76b6a7d4c11e

need qe verification.

David, can you review the fix?
Comment 10 Lou Dasaro 2013-09-06 22:16:37 UTC
Add'l commenta per 74cat request:

Anomaly is consistently reproducible with OEL 6.2 (64-bit) and Windows 7 (32-Bit)

When adding "Entity Class from Database" (using MySQL Driver) to Java or JavaFX project.

Product Version: NetBeans IDE Dev (Build 201309060001)
Java: 1.7.0_40; Java HotSpot(TM) Client VM 24.0-b55
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b40
System: Windows 7 version 6.1 running on x86; Cp1252; en_US (nb)
Comment 11 Quality Engineering 2013-09-08 01:38:31 UTC
Integrated into 'main-silver', will be available in build *201309080001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/76b6a7d4c11e
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #235059 return providers in default supplier
Comment 12 David Konecny 2013-09-08 21:12:02 UTC
> David, can you review the fix?

The patch looks safe and can go.

It might have been simpler perhaps by using a HashSet<Provider> to check for duplicates (considering you are using equals)? If PersistenceLibrarySupport.getProvidersFromLibraries() should ever return duplicate objects which are NOT instanceof Provider then these duplicates would be added to model array but that's a purely fictional problem I think.
Comment 13 Sergey Petrov 2013-09-09 04:56:11 UTC
Agree, it can be simpler, the main idea was just to restore 7.3 code, without much modification, it may  be safer for now in my opinion as this code was here(or near here) for a number of previous releases.
Comment 14 Stepan Zebra 2013-09-11 12:49:44 UTC
(In reply to Quality Engineering from comment #11)
> Integrated into 'main-silver', will be available in build *201309080001* on
> http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
> 
> Changeset: http://hg.netbeans.org/main-silver/rev/76b6a7d4c11e
> User: Sergey B. Petrov <sj-nb@netbeans.org>
> Log: #235059 return providers in default supplier

verified by QE
Comment 15 Sergey Petrov 2013-09-11 17:15:05 UTC
http://hg.netbeans.org/releases/rev/3f3acf8ba905