Saturday, 7 December 2019

NetBeans RESTful example CustomerDB does notwork


NetBeans RESTful example CustomerDB does not work



NetBeans 8.1 New Project->Samples->WebServices->REST:CustomerDB(JAVAEE6) example does not work.
1-      First of all you have to make sure that the Derby database is working.
Select from Services menu->Databases->jdbc:derby://localhost:1527/sample[app on APP]
User = app pwd=app (in my case) (user and pwd must be the same, just type the uid to pwd)
2-      Select from services Menu->Servers->GlassFish Server and right click->Start
3-      After starting the server from Projects Menu Clean and Build CustomerDB.
4-      Select Deploy customerDB by rightclick on CustomerDB
5-      Select and run CustomerDB->js->testresbeans.html



6-      Select RESTful Web Services->CustomerFacadeREST with rightclick select Test ResourceUri

7-      This means the RESTful side is working.  But there is probably something wrong in the URI.
8-      Put an alert before:
alert(req); //ARSSSSSSSSSssssssssssssssss
        if(method == 'POST') {
            c = this.xhr.post(req, mimetype, params);
        } else if(method == 'PUT') {
            c = this.xhr.put(req, mimetype, params);
        } else if(method == 'GET') {
            c = this.xhr.get(req);
            //c = this.xhr.get(req, mimetype);
        } else if(method == 'DELETE') {
            c = this.xhr.delete_(req);
        }
9-      Yes, the URI is distorted.

10-   In order to locate the mistake:
var req;
        alert(path);//ARSSSSSSSSSssssssssssssssss
        alert(baseURL);//ARSSSSSSSSSssssssssssssssss
        if( ts.isURL(path) )
            req = path;
        else
            req = baseURL+escape(path);  // ARSSSSSSSSS
       
        //change url if there are template params
        if(tparams != null) {

11-   Temporary solution is:
var req;
        alert(path);//ARSSSSSSSSSssssssssssssssss
        alert(baseURL);//ARSSSSSSSSSssssssssssssssss
        if( ts.isURL(path) )
            req = path;
        else
            req = path;
            //req = baseURL+escape(path);  // ARSSSSSSSSS