Re: using autobeans in a gwt-rpc call

412 views
Skip to first unread message

Goktug Gokdogan

unread,
Dec 20, 2012, 10:55:34 PM12/20/12
to google-web-toolkit
If using gwt-rpc is not a necessity for your project, take a look at RequestFactory which works with AutoBeans.

If you 'really' want to use GWT-RPC then you can define a 'holder' object and a CustomFieldSerializer for the holder object. For this to work you will eventually need a map from class name to class instances which can potentially cumbersome to maintain. 


On Thu, Dec 20, 2012 at 5:55 AM, Cenk Oguz <cenk...@gmail.com> wrote:
I have a small application where I am using autobeans extensively both on server and gwt side. I have an issue though with gwt-rpc calls, autobeans are apparently not serializable which causes gwt to fail with:

com.google.gwt.user.client.rpc.SerializationException: Type '$Proxy85' was not included in the set of types which can be serialized by this SerializationPolicy

Is there any obvious way that autobeans could be sent client->server side? Gwt-rpc is not good enough? Sending it over as a JSON string imposes some manual labor, seems overkill, would rather just go with POJOs in that case.

/Cenk

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/-wRCqG4lMKkJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Cenk Oguz

unread,
Dec 21, 2012, 7:17:08 AM12/21/12
to google-we...@googlegroups.com
Requestfactory is more for CRUD style operations. Don't think it makes sense in our app as most operations are rpc in nature. Will probably go with using regular POJOs in this case. Thx!

Xi

unread,
Dec 21, 2012, 9:24:49 AM12/21/12
to google-we...@googlegroups.com
gwt-rpc call needs concrete class type to do the serialization. So the generated autobean proxy won' t be serialized. 

If you do want to send your autobean object to server side, you need to use com.google.gwt.http.client.RequestBuilder (client side) to send the encoded string to server side, and create a servlet to handle this request.

I attached two files (used in our project), hope these can help you.
ServerInfoService.java
ServerInfoServlet.java

Thomas Broyer

unread,
Dec 21, 2012, 10:57:52 AM12/21/12
to google-we...@googlegroups.com


On Friday, December 21, 2012 1:17:08 PM UTC+1, Cenk Oguz wrote:
Requestfactory is more for CRUD style operations.

That just plain wrong. The early drafts of RF were indeed CRUD-oriented, but the released versions never were, particularly with ValueProxy-s added in 2.1.1 (something like a month after 2.1.0 was released)

Cenk Oguz

unread,
Dec 22, 2012, 9:53:17 AM12/22/12
to google-we...@googlegroups.com
Ok i see. Still my pojos are so light weight it seems easier to go with gwt-rpc an regular pojos for now.


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.

RyanZA

unread,
Dec 23, 2012, 9:26:14 AM12/23/12
to google-we...@googlegroups.com
Really great option if you have the flexibility to use it - use RESTful services - https://www.google.co.za/search?q=RESTful

On the server side you can use Jersey(JAX-RS) to make REST services that can use POJOs to automatically map to JSON/XML - http://jersey.java.net/ and http://jackson.codehaus.org/
On the GWT side, you can use RestyGWT which understands Jersey annotations - http://restygwt.fusesource.org/
For persistence if using appengine, you can then use https://github.com/icoloma/simpleds which uses jackson to map to JSON also

This gives a VERY nice stack that is easy to use, and allows your services to be accessed by non-GWT clients, as creating clients for RESTful services+JSON is very simple. This allows things like iOS clients or java-Android clients.

Cenk Oguz

unread,
Dec 23, 2012, 3:44:04 PM12/23/12
to google-we...@googlegroups.com
Sounds interesting, RestyGwt means moving away from gwt-rpc and making the services accessible from non-gwt clients as I understand. Will look into it, thx!


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
Reply all
Reply to author
Forward
0 new messages