Ошибка:
Unable to initiate the asynchronous service invocation (CustomService_Proxy.myMethod) -- check the network connection
Тыкаю на кнопку, выходит ошибка. делал вот по
этому примеру
TestEntryPoint:
package ru.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
/**
* Main entry point.
*
* @author nikita
*/
public class TestEntryPoint implements EntryPoint {
/**
* Creates a new instance of TestEntryPoint
*/
public TestEntryPoint() {
}
/**
* The entry point method, called automatically by loading a module that
* declares an implementing class as an entry-point
*/
public void onModuleLoad() {
final Label label = new Label("Hello, GWT!!!");
final Button button = new Button("Click me!");
final String y = "987654321";
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
CustomServiceAsync custservice = (CustomServiceAsync)GWT.create(CustomService.class);
ServiceDefTarget sdt = (ServiceDefTarget)custservice;
String moduleRelativeURL = "localhost:8084/WebGWTTest/CustomServiceImpl";
sdt.setServiceEntryPoint(moduleRelativeURL);
button.setText(sdt.getServiceEntryPoint());
AsyncCallback callback = new AsyncCallback() {
@Override
public void onFailure(Throwable caught) {
label.setText("Pichal\'");
label.setVisible(true);
Window.alert(caught.getMessage());
}
@Override
public void onSuccess(Object result) {
label.setText(result.toString());
}
};
custservice.myMethod(y, callback);
}
});
RootPanel.get().add(button);
RootPanel.get().add(label);
}
}
CustomService:
package ru.client;
import com.google.gwt.user.client.rpc.RemoteService;
/**
*
* @author nikita
*/
public interface CustomService extends RemoteService {
public String myMethod(String s);
}
CustomServiceAsync:
package ru.client;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author nikita
*/
public interface CustomServiceAsync {
public void myMethod(String s, AsyncCallback callback);
}
CustomServiceImpl:
package ru.server;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import ru.client.CustomService;
/**
*
* @author nikita
*/
public class CustomServiceImpl extends RemoteServiceServlet implements CustomService {
String seriaVersionUID;
@Override
public String myMethod(String s) {
return s+"Oo";
}
}
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
<servlet-name>CustomServiceImpl</servlet-name>
<servlet-class>ru.server.CustomServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CustomServiceImpl</servlet-name>
<url-pattern>/CustomServiceImpl</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>welcomeGWT.html</welcome-file>
</welcome-file-list>
</web-app>