Coudn't retrieve JSON

Home for older / inactive topics

Coudn't retrieve JSON

Postby vincentc » Thu Jan 10, 2013 6:56 pm

Hello,
We have installed and tested servoy mobile on a server. With the demo "servoy_mobile", everything is OK.
But I tried to adapt this demo to our CRM database, and after decades of tries, impossible to connect to the application.
Instead of the"accountmanager" of the demo, we have an "entities" table to manage the multi-tenancy (with the field "entity_id").
Here's the code of the offline_data.js

Code: Select all
*/
function ws_read(version,name)
{
   var questionParams = arguments[arguments.length-1];
   
   var retval = plugins.mobileservice.createOfflineDataDescription('data_');
   //setting the key for user_select relation
   var authenticate_info = questionParams.ws_authenticate[0];

   globals.myEntityId = authenticate_info.entityid;

   
//   //prepare personal data
   var fs_entities = globals.myentityid_to_entities;//contains the account manager contact
   traverse = new Array();
   traverse.push('entites_to_companies');
   traverse.push('companies_to_contacts');

   retval.addFoundSet(fs_entities, traverse);
   return retval;
}

function ws_authenticate(useruid,password)
{
   if (useruid == null || useruid == 'admin')
   {
      useruid = 'admin'
   }
   if (password == 'a')

   {
      //TODO check password (against pwhash column)
//      var retval = new Object();
//      retval.username = useruid;
//      return retval;
      
      var retval = new Object();
      retval.username = 'admin';
      retval.id=4
      retval.entityid=11
      return retval;
   }
   return false;
}



We always have the message "Coudn't retrieve JSON" when we logged on the application. Have you an idea of where is the problem ?

Thank you very much.
vincentc
 
Posts: 56
Joined: Thu Aug 25, 2011 11:12 am

Re: Coudn't retrieve JSON

Postby jgarfield » Mon Jan 14, 2013 4:48 pm

I have three possible guesses at what your current issue could be.

1) Assuming you are running this in "development mode" when you try to access the mobile solution, your developer needs to have the "mobile service" solution activated. The benefit of being here is that you can also run the "mobile service" as a Smart Client and put debugging breakpoints in the JSON methods. This will allow you see the requests coming in from the mobile client and make sure that they are getting executed correctly.

2) If you're trying to make this work by adapting the code that is already there, you need to make sure to not only override the "offline_data" function, but you also need to make your table specific forms with the proper prefix and form name (e.g. "prefix_full_table_name", "data_accountmanager") and ensure that they have a ws_read method, or are children of a common form that has a generic we_read method.

3) Less sure this is the problem, but it is something that I ran into that took needing to debug the generated client-side javascript to discover what was going on was that the data from the Sample solution was still cached in my local storage, and this was preventing the new data from showing up. I don't know if this is the problem you're having, but you can try to clear your local storage to be sure. In Chrome if you open the developer tools and go to the Console you can accomplish this by doing localStorage.clear(). I'm not sure if it's the same for other browsers.
Programmer.
adBlocks
http://www.adblocks.com
jgarfield
 
Posts: 223
Joined: Wed Sep 28, 2005 9:02 pm
Location: Boston, US

Re: Coudn't retrieve JSON

Postby Jan Aleman » Tue Jan 15, 2013 12:19 pm

4/ make sure the URL you put in when you build the app is the same as the one you use.
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Re: Coudn't retrieve JSON

Postby vincentc » Tue Jan 15, 2013 5:31 pm

First, a big thank for your answers.

1) yes I am in Developer Mode and I always activated "mobile service" solution when I tested the application.
I already tried to debug it in SmartClient and when I fire the ws_read, I saw that the params (version,method) are always set to 'Undefined'. Is it normal ? When I set the param values manually in the code, all is working fine.
2) yes it's already ok. My tables are companies, contacts, entites and I have the forms data_contacts, data_companies, data_entites, which extends from the form data_base. The generic ws_read method is in the form "data_base".
3) Thank you for the tip, I tried but there is no changes...
4) yes it's the case. Anyway, I replace the "localhost" by the IP of my server, to be sure to avoid the problems.

When I look the Developer Tools of Chrome, when the "Coudn't retrieve JSON" message displays, I've got this error :
"GET http://{user}:{password}@94.125.160.142:8080/servoy-service/rest_ws/magicb_mobile_service/offline_data/1/magicb_mobile 500 (Internal Server Error) "

I do not know what to do, after several days to work on it ... Thank you again for your help...
vincentc
 
Posts: 56
Joined: Thu Aug 25, 2011 11:12 am

Re: Coudn't retrieve JSON

Postby Jan Aleman » Tue Jan 15, 2013 5:48 pm

what do you see in the server log?
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Re: Coudn't retrieve JSON

Postby vincentc » Tue Jan 15, 2013 6:20 pm

Code: Select all
2013-01-15 17:19:01,335 ERROR [http-8080-1] com.servoy.extensions.plugins.rest_ws.RestWSPlugin - /servoy-service/rest_ws/magicb_mobile_service/offline_data/1/magicb_mobile [ ]
com.servoy.j2db.ApplicationException: No more licenses available
   at com.servoy.j2db.ClientState.registerClient(ClientState.java:666)
   at com.servoy.j2db.server.headlessclient.SessionClient.registerClient(SessionClient.java:316)
   at com.servoy.j2db.ClientState.applicationServerInit(ClientState.java:311)
   at com.servoy.j2db.server.headlessclient.SessionClient.<init>(SessionClient.java:199)
   at com.servoy.j2db.server.headlessclient.SessionClient.<init>(SessionClient.java:153)
   at com.servoy.j2db.server.headlessclient.HeadlessClientFactoryInternal$1.run(HeadlessClientFactoryInternal.java:76)
   at com.servoy.j2db.server.headlessclient.HeadlessClientFactoryInternal.createSessionBean(HeadlessClientFactoryInternal.java:91)
   at com.servoy.j2db.server.headlessclient.HeadlessClientFactoryInternal.createHeadlessClient(HeadlessClientFactoryInternal.java:45)
   at com.servoy.j2db.server.headlessclient.HeadlessClientFactory.createHeadlessClient(HeadlessClientFactory.java:65)
   at com.servoy.j2db.server.headlessclient.HeadlessClientFactory.createHeadlessClient(HeadlessClientFactory.java:60)
   at com.servoy.extensions.plugins.rest_ws.RestWSPlugin$1.makeObject(RestWSPlugin.java:184)
   at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1190)
   at com.servoy.extensions.plugins.rest_ws.RestWSPlugin.getClient(RestWSPlugin.java:206)
   at com.servoy.extensions.plugins.rest_ws.servlets.RestWSServlet.wsService(RestWSServlet.java:382)
   at com.servoy.extensions.plugins.rest_ws.servlets.RestWSServlet.doGet(RestWSServlet.java:144)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
   at com.servoy.extensions.plugins.rest_ws.servlets.RestWSServlet.service(RestWSServlet.java:135)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at com.servoy.j2db.server.servlets.WebServicesServlet.service(WebServicesServlet.java:9)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:615)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
   at java.lang.Thread.run(Unknown Source)
vincentc
 
Posts: 56
Joined: Thu Aug 25, 2011 11:12 am

Re: Coudn't retrieve JSON

Postby Jan Aleman » Wed Jan 16, 2013 5:00 pm

Looks like you have more clients open than licensed.... Try closing a few clients first.
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Re: Coudn't retrieve JSON

Postby vincentc » Thu Jan 17, 2013 4:53 pm

You was right, so I closed all clients and I tried again but without success (I don't think that it's the cause of my problem).

There is nothing in the log, except :

2013-01-16 17:31:55,392 ERROR [pool-2-thread-1] com.servoy.j2db.util.Debug - client_stats table missing in log server, cannot save client statistics [ ]
vincentc
 
Posts: 56
Joined: Thu Aug 25, 2011 11:12 am

Re: Coudn't retrieve JSON

Postby rgansevles » Mon Jan 21, 2013 9:53 am

vincentc,

There is an issue fixed in beta4 about headless clients that are hanging in developer.
They were consuming licenses which causes the exception you are seeing in the logs.
This is fixed in beta4, but when you restart developer you should be able to run some headless clients before this happens.

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: Coudn't retrieve JSON

Postby vincentc » Tue Feb 05, 2013 12:59 pm

The problem has been fixed when I tried without using the parent form "data_base" and his method "ws_read". I created the ws_read method (that I repeated) for each of my forms in the Service solution and now it works.... Very strange, I don't understand why there is a probem when I used the form data_base.

Now I have a second problem, synchronization (with the "sync button") seems to work from Mobile app to database, but it doesn't work in the other direction (database to mobile app) : the data aren't updated in the mobile app. Does anybody has an idea ?

Thank you very much.
vincentc
 
Posts: 56
Joined: Thu Aug 25, 2011 11:12 am

Re: Coudn't retrieve JSON

Postby jcompagner » Thu Feb 07, 2013 6:02 pm

how can database to mobile app not work?
because that is just how you get your data in to the mobile in the first place

When you do a sync we first upload all the changes the mobile client has,
then we dump all data and we get a fresh set what is not active on the server.
So after a sync you should have a complete new fresh set from the server.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Coudn't retrieve JSON

Postby vincentc » Tue Feb 12, 2013 6:13 pm

Thank you. If I understand well : when we click on the "Sync" button, it means that sync is only effective from Mobile to Database ?
Excuse me, I am french and I am not sure to have understood your explaination.
vincentc
 
Posts: 56
Joined: Thu Aug 25, 2011 11:12 am

Re: Coudn't retrieve JSON

Postby jcompagner » Tue Feb 12, 2013 6:32 pm

no
if you press sync all changes on the mobile are pushed to the server (database)
then you get a full fresh new set back from the server -> mobile.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Coudn't retrieve JSON

Postby vincentc » Wed Feb 13, 2013 4:51 pm

Ok, thank you very much Johan.
I think that the origin of my problem was that I needed to make a "refreshFoundsetFromDb", because we use an external database (SQL Server)
vincentc
 
Posts: 56
Joined: Thu Aug 25, 2011 11:12 am


Return to Archive

Who is online

Users browsing this forum: No registered users and 2 guests