module base url problems

51 views
Skip to first unread message

andy

unread,
Jun 27, 2007, 8:17:15 AM6/27/07
to Google Web Toolkit
Hi everyone,

I'm very new to GWT and I'm trying to implement some database activity
on a server and send that to the client, etc etc. Starting off simple,
just trying to get a function thats on the server side code to run. I
created the Async callback class, the impl class, followed the
tutorials and examples and samples to the letter.

It compiles fine, but I end up getting an invocation exception. For
kicks i printed out the module base url too:

Module Relative URL = http://localhost:8888/com.rwth.myApp/

com.google.gwt.user.client.rpc.InvocationException: <html><head>
<meta name='gwt:module' content='com.rwth.myApp'>
</head><body>
<iframe id='__gwt_historyFrame' style='width:0;height:0;border:0'></
iframe>
<script language='javascript' src='gwt.js'></script>
</body></html>


Well ok thats only so helpful. I'm pretty sure that my problem is with
the module relative URL. Can anyone explain what this needs to be? I
cant figure it out...

andy

unread,
Jun 28, 2007, 6:40:11 AM6/28/07
to Google Web Toolkit
Alright, I've been playing with this and trying to get it to work. I
found this alternative explanation of how to do the RPC stuff:
http://www.ibm.com/developerworks/library/os-ad-gwt3/
However, I'm still not getting it to work. Here's the layout of my
code:

src/com/rwt/client
src/com/rwt/server
src/com/rwt/public

in the client dir I have myService.java myServiceAsync.java and
myApp.java

within my myApp is where I'm trying to call the server side code,
which resides in the server dir, and is named myServiceImpl.java

Simple enough, following the examples, added the line <servlet path="/
service" class="com.rwt.server.myServiceImpl"/> within the
myApp.gwt.xml file, between the module tags. OK so far so good right?
Here's where I make the call within myApp:

-----------

myServiceAsyn myService = (myServiceAsync)
GWT.create(myService.class);

ServiceDefTarget endpoint = (ServiceDefTarget) myService;
String moduleRelativeURL = GWT.getModuleBaseURL() + "service";
System.out.println("Module Relative URL = " + moduleRelativeURL);
endpoint.setServiceEntryPoint(moduleRelativeURL);
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
// do some UI stuff to show success
myDamnText = "Hello Success!";
}

public void onFailure(Throwable caught) {
// do some UI stuff to show failure
myDamnText = "Failed";
try {
throw caught;
} catch (Throwable e) {
System.out.println(e);
// last resort -- a very unexpected exception
}
}
};

myService.getNodes(0, 2, callback);

-----------
And in the GWT dev shell I get the errors:

Unable to instantiate 'com.rwt.server.myServiceImpl
java.lang.ClassNotFoundException: com.rwt.server.myServiceImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName(Class.java:141)
at
com.google.gwt.dev.shell.GWTShellServlet.tryGetOrLoadServlet(GWTShellServlet.java:
745)
at
com.google.gwt.dev.shell.GWTShellServlet.service(GWTShellServlet.java:
237)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

And:
Unable to dispatch request

While on the java console I get:
com.google.gwt.user.client.rpc.InvocationException: Unable to find/
load mapped servlet class 'com.rwt.server.myServiceImpl'


Any help would be much much appreciated.

Jason Essington

unread,
Jun 28, 2007, 10:24:29 AM6/28/07
to Google-We...@googlegroups.com
have you compiled the server classes using javac? If you are working
in eclipse, this happens automatically, if not I believe you have to
do that part manually (or possibly as part of an ant build)

have a look in your [project_home]/bin directory, does it contain com/
rwt/server/myServiceImpl.class ?

-jason

andy

unread,
Jul 2, 2007, 6:47:48 AM7/2/07
to Google Web Toolkit
yea, I'm using Eclipse so I'm pretty sure it happens automatically...?
I'll double check the bin directory in a moment, but im guessing its
there

andy

unread,
Jul 3, 2007, 8:22:26 AM7/3/07
to Google Web Toolkit
yes the bin folder had the class file in it.

Joe

unread,
Jul 3, 2007, 9:34:18 AM7/3/07
to Google Web Toolkit
I'm having a similar problem except that there is a null string
associated with the exception.
It's driving me nuts.

In your case I notice that the line:

String moduleRelativeURL = GWT.getModuleBaseURL() + "service";

does not have a '/' in front of 'service': ie

String moduleRelativeURL = GWT.getModuleBaseURL() + "/service";

as given in your myApp.gwt.xml file:

<servlet path="/service" class="com.rwt.server.myServiceImpl"/>

I don't know if that's pertinent.

On my side, I'm using windows xp, eclipse 3.3, gwt 1.4.10.

> > > > Any help would be much much appreciated.- Hide quoted text -
>
> - Show quoted text -

Ian Bambury

unread,
Jul 3, 2007, 9:48:24 AM7/3/07
to Google-We...@googlegroups.com
If it's any use, there's a working demo here http://www.examples.roughian.com/#Page_Downloads with comments throughout - RPC and RequestBuilder - which I put up after I managed to get it going

andy

unread,
Jul 3, 2007, 10:16:08 AM7/3/07
to Google Web Toolkit
I just realized that there was an error on another window. The window
is referring to my code in DatabaseServiceImpl:

----------------------------------------------------------------------------------------------------------------------
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class DatabaseSeviceImpl extends RemoteServiceServlet
implements DatabaseService {

.......

}
----------------------------------------------------------------------------------------------------------------------

and the error says DatabaseService cannot be resolved to a type.
However, I have DatabaseService.java:

----------------------------------------------------------------------------------------------------------------------
import com.google.gwt.user.client.rpc.RemoteService;

public interface DatabaseService extends RemoteService {

String[] getNodes(int start, int max);

}
----------------------------------------------------------------------------------------------------------------------

and the Async etc etc etc. I think I have everything set up correctly
but I can't figure out whats going on.


On Jul 3, 3:48 pm, "Ian Bambury" <ianbamb...@gmail.com> wrote:
> If it's any use, there's a working demo herehttp://www.examples.roughian.com/#Page_Downloadswith comments throughout -

Matthieu

unread,
Jul 3, 2007, 1:17:29 PM7/3/07
to Google Web Toolkit
Hi Andy,

Try adding your bin directory to your classpath in Eclipse. In web
mode, if bin is not a part of your classpath, the server cannot find
the .class file associated with your DatabaseServiceImpl.

Hope this will help,

Matthieu

On Jul 3, 10:16 am, andy <djan...@gmail.com> wrote:
> I just realized that there was an error on another window. The window
> is referring to my code in DatabaseServiceImpl:
>

> ---------------------------------------------------------------------------­-------------------------------------------


> import com.google.gwt.user.server.rpc.RemoteServiceServlet;
>
> public class DatabaseSeviceImpl extends RemoteServiceServlet
> implements DatabaseService {
>
> .......
>
> }
>

> ---------------------------------------------------------------------------­-------------------------------------------


>
> and the error says DatabaseService cannot be resolved to a type.
> However, I have DatabaseService.java:
>

> ---------------------------------------------------------------------------­-------------------------------------------


> import com.google.gwt.user.client.rpc.RemoteService;
>
> public interface DatabaseService extends RemoteService {
>
> String[] getNodes(int start, int max);
>
> }
>

> ---------------------------------------------------------------------------­-------------------------------------------


>
> and the Async etc etc etc. I think I have everything set up correctly
> but I can't figure out whats going on.
>
> On Jul 3, 3:48 pm, "Ian Bambury" <ianbamb...@gmail.com> wrote:
>
>
>

> > If it's any use, there's a working demo herehttp://www.examples.roughian.com/#Page_Downloadswithcomments throughout -
> > RPC and RequestBuilder - which I put up after I managed to get it going- Hide quoted text -

andy

unread,
Jul 4, 2007, 6:57:16 AM7/4/07
to Google Web Toolkit
well, i realized I also needed to import a file, so i did that
(eclipse gave me ahint and did it for me) so now there are no errors
and no relative warnings, and I added the bin folder to the class
path, but still no go, same errors coming out of GWT as above, as same
error in the Eclipse window

> > > If it's any use, there's a working demo herehttp://www.examples.roughian.com/#Page_Downloadswithcommentsthroughout -

Matthieu

unread,
Jul 4, 2007, 11:03:28 AM7/4/07
to Google Web Toolkit
Hi Andy,

You wrote this in your previous post :

<servlet path="/service" class="com.rwt.server.myServiceImpl"/>

I don't if you already changed this line but it's not the correct form
it should be :

<servlet path="/service" class="com.rwt.server.DatabaseSeviceImpl"/>

With the good package name if it is not com.rwt.server

Good luck,

Matthieu

andy

unread,
Jul 5, 2007, 5:09:19 AM7/5/07
to Google Web Toolkit
Yes I have already changed that, but that would indeed be a problem if
I hadn't

andy

unread,
Jul 6, 2007, 9:33:09 AM7/6/07
to Google Web Toolkit
since nobody can seem to really help me, I've posted my source code at
http://betadoodle.com/gwtproblem/meshvis

Hopefully somebody can look at my code in there, in
http://betadoodle.com/gwtproblem/meshvis/umic-vis thats my project
directory.

Please help! I'm desperate! Thanks!

> > > > > myApp.gwt.xml file, between themoduletags. OK so far so good right?


> > > > > Here's where I make the call within myApp:
>
> > > > > -----------
>
> > > > > myServiceAsyn myService = (myServiceAsync)
> > > > > GWT.create(myService.class);
>
> > > > > ServiceDefTarget endpoint = (ServiceDefTarget) myService;
> > > > > String moduleRelativeURL = GWT.getModuleBaseURL() + "service";

> > > > > System.out.println("ModuleRelative URL = " + moduleRelativeURL);

Ian Bambury

unread,
Jul 6, 2007, 10:27:05 AM7/6/07
to Google-We...@googlegroups.com
It would be a darn sight easier if you zipped it up :-(
 
If you want to do that and send it to me direct (or post a link), I'll have a look
 
Ian
 
On 06/07/07, andy <dja...@gmail.com> wrote:

since nobody can seem to really help me, I've posted my source code at
http://betadoodle.com/gwtproblem/meshvis

Hopefully somebody can look at my code in there, in
http://betadoodle.com/gwtproblem/meshvis/umic-vis thats my project
directory.

Please help! I'm desperate! Thanks!

On Jul 3, 3:34 pm, Joe <joe.c.willi...@gmail.com> wrote:
> I'm having a similar problem except that there is a null string
> associated with the exception.
> It's driving me nuts.
>
> In your case I notice that the line:
>
> String moduleRelativeURL = GWT.getModuleBaseURL() + "service";
>
> does not have a '/' in front of 'service': ie
>
> String moduleRelativeURL = GWT.getModuleBaseURL() + "/service";
>
> as given in your myApp.gwt.xml file:
>
> <servlet path="/service" class="com.rwt.server.myServiceImpl"/>
>
> I don't know if that's pertinent.
>
> On my side, I'm using windows xp, eclipse 3.3 , gwt 1.4.10.

Giu Liv

unread,
Jul 11, 2007, 6:02:03 AM7/11/07
to Google-We...@googlegroups.com
Hi Andy,
don't you think your class 'myServiceImpl' should be called MyServiceImpl? With the capital M, so the line becomes

<servlet path="/service" class="com.rwt.server.MyServiceImpl "/>

Donnie

andy

unread,
Jul 11, 2007, 8:14:43 AM7/11/07
to Google Web Toolkit

Hey everyone, thanks for all the help. Turns out it was a typo (of
course). My impl class was missing an r in the name. Doh!

Reply all
Reply to author
Forward
0 new messages