invoking a GWT service from a J2SE app

4 views
Skip to first unread message

ajperez4

unread,
Jun 11, 2009, 4:08:13 PM6/11/09
to Google Web Toolkit
Hi all,

has somebody tried to invoke a GWT service from a J2SE app?

When trying to invoke the service as the same way in a GWT client app
I get the following:

Exception in thread "AWT-EventQueue-0"
java.lang.UnsupportedOperationException: ERROR: GWT.create() is only
usable in client code! It cannot be called, for example, from server
code. If you are running a unit test, check that your test case
extends GWTTestCase and that GWT.create() is not called from within an
initializer or constructor.
at com.google.gwt.core.client.GWT.create(GWT.java:91)

thanks!

Alfredo

Alex Rudnick

unread,
Jun 11, 2009, 6:23:24 PM6/11/09
to Google-We...@googlegroups.com
Hey Alfredo,

Like the error message says, calling GWT.create() only makes sense in
code runs in the browser. A lot of code in GWT ends up calling
GWT.create() -- this is how the compiler knows how to send the right
code to a given browser. So it sounds like you want to rethink what
parts of your code are running in a JVM, and which are in a browser.

For a sense of what that means in practice, you could take a look at
the docs on the topic:
http://code.google.com/webtoolkit/doc/1.6/DevGuideCodingBasics.html#DevGuideClientSide
http://code.google.com/webtoolkit/doc/1.6/DevGuideCodingBasics.html#DevGuideDeferredBinding

Hope this helps!

--
Alex Rudnick
swe, gwt, atl

Reply all
Reply to author
Forward
0 new messages