Bug 223735 - CRUD sample app does not work: NPE at org.netbeans.modules.crudsampleapplication.editor.EditorTopComponent$SaveCookieImpl.save(EditorTopComponent.java:344)
CRUD sample app does not work: NPE at org.netbeans.modules.crudsampleapplicat...
Status: VERIFIED FIXED
Product: apisupport
Classification: Unclassified
Component: Maven
7.3
PC Mac OS X
: P2 (vote)
: 7.3
Assigned To: Martin Kozeny
issues@apisupport
:
: 205783 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-12-12 15:36 UTC by Tomas Danek
Modified: 2013-03-22 08:36 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Danek 2012-12-12 15:36:40 UTC
Product Version: NetBeans IDE Dev (Build 201212100001)
Updates: Updates available
Java: 1.7.0_10; Java HotSpot(TM) 64-Bit Server VM 23.6-b04
Runtime: Java(TM) SE Runtime Environment 1.7.0_10-b18
System: Mac OS X version 10.8.2 running on x86_64; US-ASCII; en_US (nb)
User directory: /Users/tomas/Library/Application Support/NetBeans/dev
Cache directory: /Users/tomas/Library/Caches/NetBeans/dev
----------------
- create new Maven sample - CRUD sample application (Samples|Maven)
- leave everything as default
- build parent project
- run app
- try to fill in some data, hit "Save" action -> NPE 


java.lang.NullPointerException
	at org.netbeans.modules.crudsampleapplication.editor.EditorTopComponent$SaveCookieImpl.save(EditorTopComponent.java:344)
	at org.openide.actions.SaveAction.performAction(SaveAction.java:130)
	at org.openide.actions.SaveAction.performAction(SaveAction.java:107)
	at org.openide.actions.SaveAction$Delegate.actionPerformed(SaveAction.java:247)
	at org.openide.awt.ContextAction$Performer.actionPerformed(ContextAction.java:231)
...
Comment 1 Tomas Danek 2012-12-14 13:31:30 UTC
increasing to p2, since samples should work in FCS.
Comment 2 Tomas Danek 2012-12-18 12:31:56 UTC
NPE indicates that 'customer' is null on line 344, can be workarounded by invoking 'New' action prior filling data and saving. However, even after that sample does not work; getting exception indicating bad insert into db:

Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLIntegrityConstraintViolationException: INSERT on table 'CUSTOMER' caused a violation of foreign key constraint 'FOREIGNKEY_ZIP' for key (12345).  The statement has been rolled back.
Error Code: -1
Call: INSERT INTO CUSTOMER (CUSTOMER_ID, ADDRESSLINE2, ZIP, PHONE, ADDRESSLINE1, FAX, EMAIL, NAME, STATE, CREDIT_LIMIT, CITY, DISCOUNT_CODE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
	bind => [864, null, 12345, null, null, null, null, ggg, null, null, hhh, H]
Query: InsertObjectQuery(org.netbeans.modules.crudsampleapplication.dbaccess.Customer[customerId=864])
...
...  


Easy (non-robust fix)  is to modify EditorTopComponent:355
from
customer.setZip("12345");
to e.g.
customer.setZip("12347");

Better fix would be to invoke query on MICRO_MARKET table and pick first existing zip code value.
Comment 3 Jiri Rechtacek 2012-12-20 10:17:28 UTC
Reproducible also with Ant CRUD Sample on Mac, Java 7 Update 10.
Comment 5 Quality Engineering 2013-01-09 02:26:04 UTC
Integrated into 'main-golden', will be available in build *201301090001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/4edeca848040
User: Martin Kozeny <mkozeny@netbeans.org>
Log: #223735: Problem was with foreign key used on customer's zip code. Bug was fixed by replacing of setting hard-coded zip code with selected zip code from database.
Comment 6 Tomas Danek 2013-01-11 12:56:22 UTC
verified, no NPE during save now.

Product Version: NetBeans IDE 7.3 RC1 (Build 201301102100)
Java: 1.7.0_10; Java HotSpot(TM) 64-Bit Server VM 23.6-b04
Runtime: Java(TM) SE Runtime Environment 1.7.0_10-b18
System: Mac OS X version 10.8.2 running on x86_64; US-ASCII; en_US (nb)
User directory: /Users/tomas/Library/Application Support/NetBeans/7.3rc1
Cache directory: /Users/tomas/Library/Caches/NetBeans/7.3rc1
Comment 7 Martin Kozeny 2013-03-22 08:36:29 UTC
*** Bug 205783 has been marked as a duplicate of this bug. ***


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo