I currently have some time before starting with my Master thesis project which will bring me back to Android programming. So to make use of that, I started to develop a project I already wanted to implement a couple of years ago, but due to my Master studies I didn't have the time to. I'll need some beta testers soon, so keep track of my blog here to catch the moment when everything goes online.
What I can reveal so far is that it will be a web application, using Google's GWT and it will be hosted on Google's cloud computing platform App Engine.
Today I was finishing the implementation of the basic CRUD operations, using JDO and App Engine's DataNucleus DataStore. Now the app possibly needs to store large strings surely more than 255 characters. You'd think that shouldn't be a problem, but App Engine's DataStore has some implications one should be aware of. Beside these, there are some well defined core value types, under which there is the restriction that you have to use the
com.google.appengine.api.datastore.Text instead of the
String datatype if you plan to store more than 255 character strings. Ok, that shouldn't be a problem for us, should it? Well...not exactly. If you plan to use App Engine together with plain old JSP or whatever view technology that it won't be a problem, but if you use GWT you have to keep in mind that you're implementing a client-server system. The difference: the GWT client lives within the browser. So the data has to be transferred between the two end-points and has to be serializable accordingly.
com.google.appengine.api.datastore.Text isn't serializable though. This means you cannot share your POJOs between your GWT client app and server-side code. Now you have different possibilities. Some that come to my mind right now are..
- using DTOs (Data Transfer Objects) which isn't that comfortable 'cause it causes a lot of boilerplate code
- writing a serializable version of
Textand provides it for free. I just tried it out and it works seamlessly, without writing a single additional line of code. Here some steps on how to use it (available descriptions on the web are really bad).
- Download the necessary jar files from http://www.resmarksystems.com/code/:
- Include the appengine-utils-client-1.0.jar in your build path. Copy the appengine-utils-server-1.0.jar to your WEB-INF/lib folder.
- On your GWT module file add the following:
- Restart your GWT app or compile it and everything should work as expected.
Textbut also for
If you get exceptions like
java.lang.ClassCastException: java.lang.String cannot be cast to com.google.appengine.api.datastore.Textor
An IncompatibleRemoteServiceException was thrown while processing this call.then it's probably because you didn't correctly include the jar files as mentioned in step 2 above.