Hi I'm getting the following error when I attempt to call my servlet
method.
<code>
[WARN] StandardContext[]Exception while dispatching incoming RPC call
javax.servlet.ServletException: Content-Type must be 'text/plain' with
'charset=utf-8' (or unspecified charset)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.readPayloadAsUtf8(RemoteServiceServlet.java:
119)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:
178)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
com.google.gwt.dev.shell.GWTShellServlet.service(GWTShellServlet.java:
290)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
237)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
157)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
214)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:
104)</code>
I am still learning GWT (obviously I'm sure). I read through the other
posts on this topic and the found a lot of similarities to
"wanghuapeng's" posts in that I am also using Eclipse and as Ian
Bambury pointed out Eclipse had everything defaulted to the cp1252.
So, I changed the default setting in Eclipse under Window|Preferences|
General|Workspace|Text file encoding to UTF-8. Then I did a clean and
rebuilt everything. Unfortunately, there was no change.
I am using Windows XP Pro, Eclipse 3.3, Cypal and GWT 1.5 running in
Hosted Mode. Below is my "client" calling code:
<code>
public class LoginView extends Composite implements ClickListener {
private LoginInterface controller;
final VerticalPanel welcomeVerticalPanel = new VerticalPanel();
final TextBox userTextBox = new TextBox();
final PasswordTextBox passwordTextBox = new PasswordTextBox();
public LoginView() {
initWidget(welcomeVerticalPanel);
final Grid grid = new Grid();
welcomeVerticalPanel.add(grid);
grid.resize(3, 2);
final Label userLabel = new Label("User:");
grid.setWidget(0, 0, userLabel);
final Label passwordLabel = new Label("Password:");
grid.setWidget(1, 0, passwordLabel);
grid.setWidget(0, 1, userTextBox);
userTextBox.setWidth("100%");
grid.setWidget(1, 1, passwordTextBox);
passwordTextBox.setWidth("100%");
final Button loginButton = new Button();
grid.setWidget(2, 1, loginButton);
loginButton.setText("Login");
loginButton.addClickListener(this);
}
public void init(LoginInterface um) {
controller = um;
}
public void onClick(Widget sender) {
UserServiceAsync async = UserService.Util.getInstance();
async.Authenticate(userTextBox.getText(), passwordTextBox.getText(),
new AuthenticateCallback());
}
public class AuthenticateCallback implements AsyncCallback {
/* (non-Javadoc)
* @see
com.google.gwt.user.client.rpc.AsyncCallback#onFailure(java.lang.Throwable)
*/
public void onFailure(Throwable error) {
Window.alert(error.getMessage());
}
/* (non-Javadoc)
* @see
com.google.gwt.user.client.rpc.AsyncCallback#onSuccess(java.lang.Object)
*/
public void onSuccess(Object arg0) {
controller.loginSuccess((UserBase)arg0);
}
}
}
</code>
Next, I have included my servlet implementation (just a proof of
concept before I hook-up the database):
<code>
public class UserServiceImpl extends RemoteServiceServlet implements
UserService {
public UserBase Authenticate(String login, String password) {
if ((login.compareTo("gregg")==0) &&
(password.compareTo("12345678")==0))
return new UserBase(1, "gregg", "12345678", "Gregg",
"Sirrine","
gr...@domain.com");
else
return null;
}
}
</code>
Can anyone see something I've done wrong? Any clues where to look? Any
help would be appreciated I am stuck.
TIA,
Gregg