My GWT RPC AsyncCallback doesn’t work: InvocationException - java

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

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.

Related

google app engine java - redirecting based on domain

I have 2 domains for my site which is hosted in google app engine. I want to 301 redirect any request on the less desirable domain to the more desirable domain.
I have tried adding the following to my web.xml
<servlet>
<servlet-name>WebServlet</servlet-name>
<servlet-class>com.wmar.api.WebServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>WebServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>redirectFilter</filter-name>
<filter-class>com.wmar.api.WebFilterRedirect</filter-class>
</filter>
<filter-mapping>
<filter-name>redirectFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
For the servlet it hits it, but then I don't know how to just load the static resource (ideally just passing onto some default static file handler) if the domain is correct.
For the filter it doesn't hit it.
What is the best way to achieve what I want with servlet 2.5 / google app engine java?
Thanks
I realize now that the current ideal solution is to create a separate app engine project and point non-canonical domains at it which has a simple servlet that just 301 redirects to the canonical domain.
For Http to https 301s app.yaml can be used with secure: always.
As noted by konqi there are undesirable side effects by trying to do it all in the one app engine project/module.

How to configure Spring 4 WebSocket with sockjs using xml configuration

Hi my current websocket configuration is.
<websocket:message-broker application-destination-prefix="/app">
<websocket:stomp-endpoint path="/chat">
<websocket:sockjs></websocket:sockjs>
</websocket:stomp-endpoint>
<websocket:simple-broker prefix="/topic"/>
</websocket:message-broker>
and my url pattern configuration is
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
if i change to pattern to '/' then it works fine else
the give an error
GET http://localhost:8080/demoapp/chat/info 404 (Not Found)
what is wrong please suggest.
thanks
When using the *.html pattern, you're only mapping those requests to the DispatcherServlet - all other requests (in this case, all SockJS/websocket/etc requests) are ignored and an HTTP 404 error is returned by the servlet container.
So yes, you should be using "/" as a mapping pattern otherwise it won't work.
It can be hard to start writing a websocket application - a lot of new concepts and things to pay attention to. But the programming model is actually quite close to Spring MVC.
Here are a few pointers to help you:
Some "light reading" of the reference documentation (schemas are really helpful)
Try the official getting started guide on websocket
Take a look at well designed example applications such as a portfolio app or a chat room app
How about
add this code
<async-supported>true</async-supported>
on web.xml file
<servlet>
<servlet-name>DispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
I'm use like this code
It work and doesn't show Path error

spring web services configuration in web.xml?

I am using spring-ws and I have the below configuration in my web.xml
<servlet>
<servlet-name>spring-ws</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>**transformWsdlLocations**</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>spring-ws</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Here I have transformWsdlLocations configured. Please explain me the use of transformWsdlLocations here. I am using the dynamic WSDL generation concept.
Is transformWsdlLocations really required for dynamic WSDL generation?
Thanks!
Given that it only takes a couple of minutes to remove the value and redeploy your application, I would advise you to do that and see what happens. Just try accessing the WSDL through "localhost" and through "127.0.0.1", and see what differences there are.
However I'll explain what you should see here...
When you read the WSDL that is generated, you should find that there are URLs in there.
i.e. From the local machine you might use:
http://localhost:8080/myservice.wsdl
But when you go live, your service might be:
http://www.<yourdomain>.com/myservice.wsdl
You don't want someone downloading the WSDL from your production domain to have those values populated with "localhost:8080". Likewise, you can't test your service properly if the URL being returned in the WSDL is for your production server. Or you might have multiple production services with different URLs.
transformWsdlLocations ensures that this is generated dynamically based on whatever URL is being used to access the service.
It is not needed for dynamic WSDL generation, but I have always found it very useful to have it. However, it is not enabled by default, so if you do want those URLs to be generated dynamically then it's best to include it.

How to enable WebDAV related methods in Tomcat

How to enable WebDAV related methods in Tomcat: LOCK, UNLOCK, PROPFIND etc.? I've installed a servlet that handles these methods but when I try to connect to it the server returns 501 Not Implemented error.
Standard GET, POST etc. methods work fine.
Solved by changing web.xml content:
<servlet-mapping>
<servlet-name>DemoWebDAVServlet</servlet-name>
<url-pattern>/dav</url-pattern>
</servlet-mapping>
had to be changed to
<servlet-mapping>
<servlet-name>DemoWebDAVServlet</servlet-name>
<url-pattern>/dav/*</url-pattern>
</servlet-mapping>

Why use <servlet-mapping> in web.xml(Deployment Descriptor) in jsp/servlet?

<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/HelloWorld.do</url-pattern>
</servlet-mapping>
Why do we use url-pattern inside servlet-mapping tag. Why not in servlet tag itself.
It's seems just an extra tag to write.
Is it just because servlet/jsp spec writers decided to do so or has it some logical reason behind its existance ?
This is more likely due to the fact that servlets were intended to support multiple protocols, and not just HTTP. URL patterns are specific to HTTP alone, and therefore the mapping of the servlet to HTTP URL patterns is done in a servlet-mapping tag, instead of the servlet tag which is used for declaring the more generic properties of the servlet.
u may try to write another that also linked to the same servlet,and then u will know that the servlet can have more than one servlet-mapping.
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/HelloWorld.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/HelloWorld2.do</url-pattern>
</servlet-mapping>
I agree with Vineet Reynold that servlet-mapping is used to provide support for different protocols available for communication in network. therfore, url-pattern tag let know the servlet the type of protocol ie. HTTP requesting the service.
The limitations and weaknesses of the standard servlet url pattern was a driving factor behind many of the early MVC frameworks (Struts etc). No support for regular expression matching, or even ant-style patterns. No support for url exclusion patterns etc etc.
As to why the specification is the way it is (and still continue to be), I have no idea. The only people who know for sure are the ones who wrote the specs.

Categories