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...
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.
have a look in your [project_home]/bin directory, does it contain com/
rwt/server/myServiceImpl.class ?
-jason
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 -
----------------------------------------------------------------------------------------------------------------------
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 -
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 -
> > > If it's any use, there's a working demo herehttp://www.examples.roughian.com/#Page_Downloadswithcommentsthroughout -
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
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);
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.
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!