Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Need help with XJSONDataSource

    SmartGWT ver. 2.2

    here is the data which is hosted on http://localhost:9090/cdr/records (just the file in the "webapps/cdr" directory)
    Code:
    callback([{"id":"1","value":"Yes""},{"id":"2","value":"No"},{"id":"3","value"="Maybe"}];)

    here is the code which is hosted on http://localhost:8080/cdr/cdr.html
    Code:
    public void onModuleLoad() {
      XJSONDataSource remoteDS = new XJSONDataSource();
      remoteDS.setDataFormat(DSDataFormat.JSON);
      remoteDS.setDataURL("http://localhost:9090/cdr/records");
    		
      DataSourceTextField fId = new DataSourceTextField("id", "ID");
      DataSourceTextField fName = new DataSourceTextField("value", "Value");
      fId.setPrimaryKey(true);
    		
      remoteDS.setFields(fId, fName);
    		
      ListGrid lg = new ListGrid();
      lg.setAutoFetchData(true);
      lg.setHeight100();
      lg.setWidth100();
      lg.setDataSource(remoteDS);
    		
      lg.draw();
    }
    as result I have the empty grid and the only message (in the eclipse's console) is:
    Code:
    "Uncaught JavaScript exception [Script error.] in , line 0"
    Please, help me to determinate the error.

    #2
    I am getting the same issue. Can anyone help ??? Please....

    Comment


      #3
      Since your JSON data in on top level, you have to define the xpath as follows.

      setRecordXPath("/");


      If JSON data is on 2 nd level and JSON varibale name is 'list'

      setRecordXPath("/list");

      Comment


        #4
        Hi tgallage,

        I tried what you suggested, but I still get the same error.

        On the web service I get the stack trace as
        Code:
        6266 [http-8080-1] ERROR org.hibernate.AssertionFailure - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
        org.hibernate.AssertionFailure: possible non-threadsafe access to the session
        	at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:124)
        	at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:898)
        	at org.hibernate.loader.Loader.doQuery(Loader.java:773)
        	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
        
        ...
        ...
        
        
        SEVERE: TransactionSynchronization.afterCompletion threw exception
        org.springframework.dao.InvalidDataAccessApiUsageException: Transaction not active; nested exception is java.lang.IllegalStateException: Transaction not active
        
        
        ...
        ...
        
        
        SEVERE: Servlet.service() for servlet Jersey Web Application threw exception
        org.hibernate.AssertionFailure: possible non-threadsafe access to the session

        The webservice uses jersey for web-service and has spring-jpa based backend. The service gives no error when invoked from a browser or rest-client tool of firefox.

        Also, to make the callback stuff work, I changed the rest response on the webservice to wrap it as callback method like this -

        Code:
        return "isc.Comm._scriptIncludeReply_0(" + jsonData + ")";
        The jsonData is a list of a hibernate mapped entity (say Department) and this entity has 1:M relationship too, so a list of mapped entities (say Employees ) is also there in the jsonData. The stacktrace shows errors at the point where it is loading the nested entities. The same works through browser as I mentioned earlier.

        Pls reply in case the query is not clear. Any help would be highly appreciated. I am stuck in this issue for 1 week.

        Comment


          #5
          Again, this is not a SmartGWT problem, but we do have commercial services available if you want help from Isomorphic anyway. Thanks.

          Comment


            #6
            The problem doesn't happen when I use GWTRPCDatasource by calling the rest API using HttpConnector on the server (impl) file. It only and only happens when I use XjsonDataSource. Who knows it might be because of smartgwt...!!!

            Now since your support is not available, I will stick to GWTRPCDatasource.

            Thanks anyways !

            Comment


              #7
              They said their support is available - but you need to pay for it. Sounds pretty reasonable given that it is your server code (not SmartGWT) that is crashing.

              If I had to guess, the reason you don't get this error in your browser is that the browser is making one request at a time - while your SmartGWT application has sent a request for more than one datasource. Try a simple case where you only use a single datasource.

              Comment


                #8
                The issue you have is something related to the configuration of you spring beans with the web layer.

                You succeeded in usual single Browser because it is working in synchronous manner. Try with simultaneous browser requests or test tool like JMeter , then the application would probably fail like in JSON scenario.

                1) How do you handle the web session in your application, like standard JEE way or some other way ?

                2) What is the approach used to implement Web tier ?

                3)How do you wire the spring beans into the web requests where you implemented JSON response ?

                Comment


                  #9
                  Your response data goes wrong format for XJSONDataSource format

                  The correct format looks like this:

                  isc.Comm._scriptIncludeReply_2({ ResultSet: { status: 0, errors: "success", totalResultsAvailable: 0,totalResultsReturned: 1,firstResultPosition: 1,Result: [ { ContractPurchaseSupplierid: "156" , ContractPurchaseSuppliername: "佛山市南海必得福无纺布有限公司" , ContractPurchaseContractcode: "E/CP09/0106" , ContractPurchaseContractamount: "58951000.00" , ContractPurchasePurchasecount: "131" , ContractPurchasePurchaseamount: "6745065.30" } ] } });

                  Comment

                  Working...
                  X