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 223718 - Customer Database sample does not work with data
Summary: Customer Database sample does not work with data
Status: VERIFIED WONTFIX
Alias: None
Product: webservices
Classification: Unclassified
Component: REST (show other bugs)
Version: 7.3
Hardware: PC Windows 7 x64
: P3 normal (vote)
Assignee: Milan Kuchtiak
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-12 12:45 UTC by Jiri Skrivanek
Modified: 2016-07-07 10:06 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Skrivanek 2012-12-12 12:45:19 UTC
Customer Database (Java EE 5) sample (and Customer Database on Spring as well)  does not show any data because of recent changes in web services. To reproduce:

- open new project wizard
- choose "Samples|Web Services|REST: Customer Database (Java EE 5)"
- finish wizard
- run project and confirm Jersey configuration as offered (server library, webresources path)
- index page is opened but it shows no data

IMO there are two problems:
- it needs to replace http://localhost:8080/CustomerDB/resources by http://localhost:8080/CustomerDB/webresources in all javascript files
- usage of '@uri' in javascript needs to be revised because for me it returns JSON response without this field. For example

http://localhost:8080/CustomerDB/webresources/customerdb.customer/2

{"addressline1":"9754 Main Street","addressline2":"P.O. Box 567","city":"Miami","creditLimit":"50000","customerId":"2","discountCode":{"discountCode":"77","rate":"11.00"},"email":"www.new.example.com","fax":"305-555-0149","name":"New Enterprises","phone":"305-555-0148","state":"FL","zip":"95035"}

Product Version: NetBeans IDE Dev (Build 201212120001)
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: Windows 7 version 6.1 running on amd64; Cp1250; en_US (nb)
Comment 1 Denis Anisimov 2012-12-12 18:54:13 UTC
web-main#13152d38d79f
Comment 2 Quality Engineering 2012-12-14 02:44:33 UTC
Integrated into 'main-golden', will be available in build *201212140001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/13152d38d79f
User: Denis Anisimov <ads@netbeans.org>
Log: Fix for BZ#223718 - Customer Database sample does not work with data
Comment 3 Jiri Skrivanek 2013-01-02 14:55:35 UTC
Reopening because "Customer Database on Spring" sample still doesn't show any data. If I try "Test Resource URI" on "RESTful Web Services|CustomerRESTFacade" it fails and reason is
[com.sun.istack.SAXException2: A cycle is detected in the object graph. This will cause infinitely deep XML: customerdb.Customer[customerId=2] -> customerdb.DiscountCode[discountCode=M] -> customerdb.Customer[customerId=2]]

"Customer Database" sample shows data but it is not possible to create or edit data which is P3 problem IMO. It is because discountCode is from character (e.g. 'H') translated to ASCII value (e.g. 72) in web service response (http://localhost:8080/CustomerDB/webresources/customerdb.discountcode). And also there is mapping to MICRO_MARKET table through the ZIP column. I would recommend to rewrite both these samples to use just single table without references (e.g. MANUFACTURER) and use Java EE 6. At least in the next release.
Comment 4 Denis Anisimov 2013-01-09 08:05:02 UTC
(In reply to comment #3)
> Reopening because "Customer Database on Spring" sample still doesn't show any
> data. If I try "Test Resource URI" on "RESTful Web Services|CustomerRESTFacade"
> it fails and reason is
> [com.sun.istack.SAXException2: A cycle is detected in the object graph. This
> will cause infinitely deep XML: customerdb.Customer[customerId=2] ->
> customerdb.DiscountCode[discountCode=M] -> customerdb.Customer[customerId=2]]
Right, Entity bean DiscountCode doesn't have @XmlTransient annotation.
> 
> "Customer Database" sample shows data but it is not possible to create or edit
> data which is P3 problem IMO. It is because discountCode is from character
> (e.g. 'H') translated to ASCII value (e.g. 72) in web service response
> (http://localhost:8080/CustomerDB/webresources/customerdb.discountcode). And
> also there is mapping to MICRO_MARKET table through the ZIP column. I would
> recommend to rewrite both these samples to use just single table without
> references (e.g. MANUFACTURER) and use Java EE 6. At least in the next release.
Discount code is an entity bean which is referenced from Customer. That's the issue (not character->ASCII translation). So created/updated Customer should
reference to the *existing* DisountCode.
Current UI state (JS code) designed badly: it doesn't allow to conform above requirement. There should be chooser for DiscountCode (f.e. "selection" element
like ComboBox).
I agree that samples has to be rewritten to avoid such references.

I'm going to fix the issue with showing data for Spring case.
The remaining issues should be fixed in the next release.
Comment 5 Denis Anisimov 2013-01-09 11:34:02 UTC
Fix for data showing in Spring sample.
web-main#2c6c8661dc88

Samples have to be rewritten to get "update" and "create" working in the next release.
Comment 6 Jiri Skrivanek 2013-01-09 14:39:28 UTC
Thank you for the fix. I agree that update/create will be fixed in the next release.
Comment 7 Quality Engineering 2013-01-10 03:33:42 UTC
Integrated into 'main-golden', will be available in build *201301100107* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/2c6c8661dc88
User: Denis Anisimov <ads@netbeans.org>
Log: Fix for BZ#223718 - Customer Database sample does not work with data
Comment 8 Milan Kuchtiak 2013-07-31 15:56:25 UTC
IMO, the sample is still not working completely.
The GET method works, but POST not. (Testing with GlassFish4)

The JavaScript code looks quite obsolete. Would be fine to rewrite the code to some modern framework. e.g. AngularJS.
Comment 9 Milan Kuchtiak 2013-08-06 09:49:00 UTC
Rewritten to backbone library:
hg.netbeans.org/web-main/rev/a40f98c28957

Still update, create doesn't work
Comment 10 Quality Engineering 2013-08-07 02:25:06 UTC
Integrated into 'main-silver', will be available in build *201308062300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/a40f98c28957
User: Milan Kuchtiak <mkuchtiak@netbeans.org>
Log: #223718 sample rewritten to Backbone library
Comment 11 Milan Kuchtiak 2013-08-19 07:49:10 UTC
It would be worth to re-write the client to more RESTful AngularJS resources framework.
Comment 12 Martin Balin 2016-07-07 09:54:19 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss