aspose file tools*
The moose likes GWT and the fly likes RPC fails after working couple of times. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "RPC fails after working couple of times." Watch "RPC fails after working couple of times." New topic
Author

RPC fails after working couple of times.

Laurence Turpin
Greenhorn

Joined: May 21, 2012
Posts: 19
Hello,

I'm using Windows 7 Eclipse Juno with the latest Google App Engine plugin.
I'm trying to write a program to check I understand how to store things in the Google App Engine datastore and also how to use GWT RPC.

The program has 2 text boxes for entering a name and address.
See the following image.


The name and address values are placed in a object called ContactDetails which is kept in the shared directory.
They are passed to to the datastore using GWT RPC and placed in a Entity kind called storedcontact.
The image below shows my directory structure.

The Image below shows the values getting stored in the development datastore.

Once in the datastore the I retrieve all the names and addresses from the datastore
Then I return them back to client side via the GWT RPC and display them in a flex table as shown below

The problem is it works a couple of times and then it fails.
I put in some system.out.println statements in an effort to diagnose the problem.
Below is the console display:


I can't understand why it will work twice and then fail?
below is my code.







Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10403
    
    8


The stack trace is telling you that the array you initialized does not have sufficient capacity to add more data. Check the array size and the element size in your result.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Laurence Turpin
Greenhorn

Joined: May 21, 2012
Posts: 19
Thank you Manesh Godbole for replying to my problem.
If you look at the code for RpcServiceImpl.storeContact method line 39 you will see that I have already printed the array size to the console

Each time I enter a new set of values the array is incremented to a larger size as you can see in the stack trace lines 12, 15, and 19
I have repeated the what I have sent to the console below

Note that in the last name and address I entered is Phil Mitchell 7 Albert Square
He appears to be in the datastore and the array is set for 3 entitys
So why is he not in the result? This is the problem
The following 3 lines give me the array size and display the array size to the console. These three lines appear to be working

Why is Phil Mitchell in the datastore and is counted as in the datastore, but the for loop cannot find him?
Michael Joyner
Greenhorn

Joined: Nov 14, 2012
Posts: 4
Try switching over to ArrayList<ContactDetails> instead, it appears the source you are getting your count from is not giving you the real number of records perhaps? With an ArrayList, you just use #add(member) as needed, and you don't have to worry about adding past end of array.


Laurence Turpin
Greenhorn

Joined: May 21, 2012
Posts: 19
Thank you Micheal Joyner for your reply my program now works.
I had to make a few additional changes to the Rpc return types.
I have shown the new code below.



The addToTable method also needed changing too as shown below
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RPC fails after working couple of times.