0

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

  • Is your RPC implementation registered as servlet in your `web.xml` file? – Gilberto Torrezan Feb 20 '14 at 16:54
  • Yes, I have added them in the web.xml – user3314759 Feb 20 '14 at 17:24
  • ... and you RPC interface contains the `@RemoteServiceRelativePath("comp/ChartGenerator")` annotation? (Note: depending on your web server configuration, you might need to use `@RemoteServiceRelativePath("../comp/ChartGenerator")` instead.) – Gilberto Torrezan Feb 20 '14 at 17:56
  • Thanks Gilberto. I didn't use @RemoteServiceRelativePath("comp/ChartGenerator") in my RPC interface. Just now I added this relative path and test my application again, the error is still the same. Any suggestion? – user3314759 Feb 20 '14 at 19:01
  • I have tried both versions @RemoteServiceRelativePath("../comp/ChartGenerator") and @RemoteServiceRelativePath("comp/ChartGenerator"). The same error message in the caller. How to check my web server configuration? I test my application in development mode. So it is http://127.0.0.1:8888/comp/chartGenerator . Does it look normal? Many thanks! – user3314759 Feb 20 '14 at 19:18
  • That's weird. Try debugging your client (taking a special look on what URLs are called when the RPC is made) and your server (checking if there isn't errors on startup or elsewhere). – Gilberto Torrezan Feb 20 '14 at 19:41
  • you may forget to recompile your java code: i mean you server side code and refresh or restart your server. – timmz Feb 21 '14 at 07:12

1 Answers1

0
  1. Prefix "/context_root" in url pattern defined in web.xml. In your case the url pattern will be "/comp/ChartGenerator".
  2. Use annotation @RemoteServiceRelativePath("ChartGenerator") in RemoteService interface.
Braj
  • 46,415
  • 5
  • 60
  • 76
  • Many thanks! How to know my context_path? Should it be something like /C:/SERVERS/x/y/x/yourApp/WEB-INF/classes ? – user3314759 Feb 21 '14 at 00:36
  • Normally context path is name of your application. Please read about it based on your web container. Try this link to understand context path for tomcat. [link] (http://www.mulesoft.com/tcat/tomcat-context) – Braj Feb 21 '14 at 08:35
  • Hello Braj, thanks a lot for your prompt help! My application name is comp. I have added @RemoteServiceRelativePath("comp/ChartGenerator") in my RemoteService interface. For url pattern in web.xml, I tried 3 different versions of context path in url pattern (1) /C:/*/workspace/comp/war/WEB-INF/classes/comp/ChartGenerator (2) /C:/*/workspace/comp/ChartGenerator (3) /C:/*/workspace/comp/war/WEB-INF/classes/com/test/client/ChartGenerator but none of them work. I got the same error message. – user3314759 Feb 21 '14 at 23:58
  • The detailed error message is com.google.gwt.user.client.rpc.StatusCodeException: 404

    HTTP ERROR: 404

    NOT_FOUND

    RequestURI=/comp/chartGenerator

    Powered by Jetty://


    Any suggestion? Many thanks!
    – user3314759 Feb 21 '14 at 23:59
  • Context path does not represent absolute path of the application. In tomcat it is name of war file. Please read it again [Link] https://tomcat.apache.org/tomcat-5.5-doc/config/context.html Now it’s clear from the error message that request URI is "/comp/chartGenerator" and as per your comments "comp" is your application name. URL pattern follows case sensitivity. As per error message and web.xml "chartGenerator" may be not in same case in url pattern and annotation. – Braj Feb 22 '14 at 07:13
  • Please confirm it again: 1. /comp/chartGenerator in web.xml and annotation @RemoteServiceRelativePath("chartGenerator") in RemoteService interface 2. /comp/displayChart in web.xml and annotation @RemoteServiceRelativePath("displayChart") in RemoteService interface – Braj Feb 22 '14 at 07:14
  • Thank you so much Braj! I have solved this problem. Yes, it's case problem. I changed to small case such as chartGenerator and displayChart in url-pattern and @RemoteServiceRelativePath. It works perfect! Awesome! You helped me a lot! – user3314759 Feb 23 '14 at 21:35