I am having trouble getting a simple GWT RPC to work. I got the
default
created by the Application Builder, webAppCreator to work fine in
both development mode and on my server. I then tried to create my own
that passes back an object.
When I run it in hosted mode, the Jetty tab says greetServlet:
An IncompatibleRemoteServiceException: This application is out of
date, please click the refresh button. I tried not only doing that,
in both Internet
Explorer and Mozilla, but also changing to another computer and
resetting up all
the files. I always get this error. (I also got the same error
message
when I ran it in build mode on my Servlet Container. This was the
first
time I ran the application in the browser.)
Here is the code where I set up my call to the service in
MyWebApp.java,
private final ThreeAsync greetingService = GWT.create(Three.class);
greetingService.GE(LastName,FirstName, new
AsyncCallback<Employee>() {
public void onFailure(Throwable caught) {
// Show the RPC error message to the user
dialogBox.setText("Remote Procedure Call - Failure");
serverResponseLabel.setHTML("server Error");
dialogBox.center();
closeButton.setFocus(true);
}
public void onSuccess(Employee result) {
dialogBox.setText("Remote Procedure Call");
serverResponseLabel.removeStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(result.toString());
dialogBox.center();
closeButton.setFocus(true);
}
});
}
And here is the Three.java and ThreeAsync.java files I use in my
client
directory (C:\g3\src\com\mycompany\mywebapp)
package com.mycompany.mywebapp.client;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.mycompany.mywebapp.shared.Employee;
/**
* The async counterpart of <code>Three</code>.
*/
public interface ThreeAsync {
void GE(String LN, String FN, AsyncCallback<Employee> callback)
throws IllegalArgumentException;
}
package com.mycompany.mywebapp.client;
import com.mycompany.mywebapp.shared.Employee;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
* The client side stub for the RPC service.
*/
@RemoteServiceRelativePath("greet")
public interface Three extends RemoteService {
public Employee GE(String LN, String FN) throws
IllegalArgumentException;
}
One of the Google Web Posts mentioned that this can be caused by a
problem
with the @RemoteServiceRelativePath. I do not understand what is
supposed
to be in the parentheses for this argument.
Here is the definition of the Employee class
package com.mycompany.mywebapp.shared;
import java.util.Date;
import java.io.*;
public class Employee implements Serializable{
public String LastName;
public String FirstName;
public float Salary;
public Date BirthDate;
public String toString () {
return LastName+", "+FirstName;
}}
And here is my test of the server code in the server directory:
package com.mycompany.mywebapp.server;
import com.mycompany.mywebapp.client.Three;
import com.mycompany.mywebapp.shared.FieldVerifier;
import com.mycompany.mywebapp.shared.Employee;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import java.util.Date;
/**
* The server side implementation of the RPC service.
*/
@SuppressWarnings("serial")
public class ThreeImpl extends RemoteServiceServlet implements Three {
Employee [] EmployeeList;
int EmployeeCount;
public Employee GE(String LastName, String FirstName) throws
IllegalArgumentException {
// Verify that the input is valid.
if (!FieldVerifier.isValidName(LastName) || !
FieldVerifier.isValidName(FirstName)) {
// If the input is not valid, throw an IllegalArgumentException
back to
// the client.
throw new IllegalArgumentException(
"Both Name must be at least 4 characters long");
}
Employee ReturnThis;
ReturnThis = new Employee();
ReturnThis.LastName=LastName;
ReturnThis.FirstName=FirstName;
ReturnThis.Salary = 20000;
ReturnThis.BirthDate = new Date(1990,10,12);
return
ReturnThis;
}
}
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.