PDA

View Full Version : gwt+spring deploy tomcat failed



q1111
12 Apr 2011, 11:49 PM
gwt+spring run in host mode is fine. but when i deployed war in tomcat ,rpc call is wrong.
web.xml

<servlet>
<servlet-name>gwt-controller</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>

<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>gwt-controller</servlet-name>
<url-pattern>*.gwt.rpc</url-pattern>
</servlet-mapping>


gwt-controller-servlet.xml


<bean id="handlerMapping"
class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
<bean name="/testgwt5/greet.gwt.rpc"
id="greetService"
class="com.zeng.server.GreetingServiceImpl">
</bean>



GreetingService.java


@RemoteServiceRelativePath("greet.gwt.rpc")
public interface GreetingService extends RemoteService {
String greetServer() throws IllegalArgumentException;
}


TestGWT5.java


greetingService.greetServer(
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
// Show the RPC error message to the user
dialogBox
.setText("Remote Procedure Call - Failure");
serverResponseLabel
.addStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(SERVER_ERROR);
dialogBox.center();
closeButton.setFocus(true);
}
public void onSuccess(String result) {
dialogBox.setText("Remote Procedure Call");
serverResponseLabel
.removeStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(result);
dialogBox.center();
closeButton.setFocus(true);
}
});


when i deploy on tomcat ,always run to onFailure(Throwable caught){}
Please help me. thanks a lot.

q1111
13 Apr 2011, 12:37 AM
GWTController.java


public abstract class GWTController extends RemoteServiceServlet implements Controller, ServletContextAware{
private static final Log log = LogFactory.getLog(GWTController.class);
public ServletContext m_servletContext;

public ModelAndView handleRequest (HttpServletRequest request, HttpServletResponse response) throws Exception
{
doPost (request, response);
return null;
}
public void setServletContext (ServletContext servletContext)
{
this.m_servletContext = servletContext;
}
public ServletContext getServletContext ()
{
return m_servletContext;
}
}


GreetingServiceImpl.java


public class GreetingServiceImpl extends GWTController implements
GreetingService {
public String greetServer() throws IllegalArgumentException {
...
}
}