问题
I developed a GWT application and make a AsyncCallback a jfreechart generated in server side. But there is an error returning a InvocationException. The detailed error message is here 404 html com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:209) callback.onResponseReceived(this, response);
I used GWT 2.5.1 and jre7 and eclipse juno 4.2 My Service Interface, Asynchronous Interface and Implementing Service codes are the same as this example http://www.jfree.org/phpBB2/viewtopic.php?t=19080&sid=f627bee2b70f0f512009d737957b8eee
I have added servlet in my web.xml
<servlet>
<servlet-name>ChartGenerator</servlet-name>
<servlet-class>com.test.server.ChartGeneratorImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>DisplayChart</servlet-name>
<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ChartGenerator</servlet-name>
<url-pattern>/comp/ChartGenerator</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>DisplayChart</servlet-name>
<url-pattern>/comp/DisplayChart</url-pattern>
</servlet-mapping>
I checked the documentation of RPC and it said
InvocationException can happen for many reasons: the network may be disconnected, a DNS server might not be available, the HTTP server might not be listening, and so on.
My internet is working well.
Any suggestion?
Many thanks!
Helen
回答1:
- Prefix "/context_root" in url pattern defined in web.xml. In your case the url pattern will be "/comp/ChartGenerator".
- Use annotation @RemoteServiceRelativePath("ChartGenerator") in RemoteService interface.
来源:https://stackoverflow.com/questions/21913859/my-gwt-rpc-asynccallback-doesn-t-work-invocationexception