Trouble with setting entry point for GWT service
- by Xorty
Hello. I've followed serveral tutorials and read official docs at code.google.com, but still didn't manage to resolve this thing.
I am creating simple service that'll check if user can be logged.
CLIENT SIDE:
public interface LoginService extends RemoteService {
/**
* Checks, if user has valid login.
* @param user User's login.
* @return True if such a login is in the database.
*/
boolean isValidUser(User user);
}
And here is Async interface:
public interface LoginServiceAsync {
/**
* Checks, if user has valid login.
* @param user User's login.
* @param callback the callback to return True if such a login is in the database.
*/
void isValidUser(User user, AsyncCallback<Boolean> callback);
}
SERVER SIDE:
public class LoginServiceImpl extends RemoteServiceServlet implements LoginService {
/**
* serial version UID
*/
private static final long serialVersionUID = 1044980345057997696L;
/**{@inheritDoc} */
@Override
public boolean isValidUser(User user) {
boolean success = true; //TODO change
}
}
Now I have entry point class MailClient.java. I append here widget like:
CustomWidgets.getLoginWidget(this);
// access rootPanel and append widget
Now I need to make actual call to my service, and here is problem:
LoginServiceAsync loginService = (LoginServiceAsync) GWT.create(LoginService.class);
User user = new User(boxName.getText(), boxPassword.getText());
AsyncCallback<Boolean> callback = new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage()); //TODO change
}
@Override
public void onSuccess(Boolean result) {
Window.alert("success"); //TODO change
}
};
((ServiceDefTarget) loginService).setServiceEntryPoint(GWT.getModuleBaseURL()+"login"); // dunno what should be here
So to recap, I don't know how to set service's entry point.
Here's my MailClient.gwt.xml file:
<module>
<inherits name="com.google.gwt.user.User"/>
<inherits name="com.google.gwt.user.theme.standard.Standard"/>
<entry-point class="com.xorty.mailclient.client.MailClient"/>
<servlet path="/login"
class="com.xorty.mailclient.server.servlets.LoginServiceImpl" />
<inherits name="com.xorty.mailclient.MailClient"/>
<inherits name="com.xorty.mailclient.MailClient"/>
<inherits name="com.xorty.mailclient.MailClient"/>
<inherits name="com.xorty.mailclient.MailClient"/>
<inherits name="com.xorty.mailclient.MailClient"/>
</module>
My web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>MailClient.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>LoginService</servlet-name>
<servlet-class>com.xorty.mailclient.server.servlets.LoginServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginService</servlet-name>
<url-pattern>/com.xorty.mailclient.MailClient/login</url-pattern>
</servlet-mapping>
</web-app>
And here is screenshot of project structure: