I am trying to become familiar with using the GWT api to create web based applications. I have been following some tutorials on GWT and have not yet been able to make an RPC call. Looking at the problem with a broad scope, my goals are to make a server call to run a series of database tests that I know work (ive tested this code).
—EDIT—
I think that the problem here is that the resource is being looked for here:
/MatesWeb/org.matesweb.Main/peopleService
when I think it should be looked for here:
/MatesWeb/peopleService
—END_EDIT—
Here is the info and code I feel is relevant:
-using netbeans
-error that I am getting is “/MatesWeb/org.matesweb.Main/PeopleService – description – The requested resource is not available.”
-GWT.getModuleBaseURL() returns: :8080/MatesWeb/org.matesweb.Main/
-URL in browser is: :8080/MatesWeb/
from web.xml file
<servlet>
<servlet-name>peopleService</servlet-name>
<servlet-class>org.matesweb.server.PeopleServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>peopleService</servlet-name>
<url-pattern>/peopleService</url-pattern>
</servlet-mapping>
From PeopleService Service
package org.matesweb.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("PeopleService")
public interface PeopleService extends RemoteService {
String[] saveGetPerson(String[] persInfo);
int runTests();
}
From PeopleServiceImpl
package org.matesweb.server;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import org.matesweb.client.PeopleService;
import org.matesweb.server.tests.DbTest;
class PeopleServiceImpl extends RemoteServiceServlet implements PeopleService {
@Override
public String[] saveGetPerson(String[] persInfo) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int runTests()
{
int retInt;
DbTest dbTest = new DbTest();
retInt = dbTest.runTests();
return retInt;
}
}
From PeopleServiceAsync
package org.matesweb.client;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface PeopleServiceAsync
{
void saveGetPerson(String[] persInfo, AsyncCallback<String[]> persInformation);
void runTests(AsyncCallback<Integer> retInt);
}
Any idea of whats going on here?
Cheers,
Nick
The
@RemoteServiceRelativePathannotation is used to decide what url to hit. This path to the server is relative to the compiled module itself – the gwt app loaded from the path/MatesWeb/org.matesweb.Main/, so the service is being sought out at/MatesWeb/org.matesweb.Main/PeopleService. I assume this means you have an html file in theMatesWeb/directory (probably the .war file is called MatesWeb?), and inside of there exists the compiled app inorg.matesweb.Main/, including the initial JS file,org.matesweb.Main.nocache.js.If you want to tell the service to be found at
/MatesWeb/peopleService, you have two options. The first is to modify the annotation to back up a directory, something like this:Using
.., I indicate the parent directory, and I also changed the case of the path part ‘peopleService’ – this may or may not matter. A second option is to set the url programmatically:As referenced in the
@RemoteServiceRelativePathjavadocs http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/user/client/rpc/RemoteServiceRelativePath.html.If, instead, you want to leave the client as is and tell the server that this service should be at the path the client expects, you can modify the
web.xmlto make the servlet available at the path that the client is currently expecting to find it:Note again that I’ve changed the case – it may not matter, but I generally like to be consistent.