cometd spring Request method 'POST' not supported for /cometd/handshake

843 views Asked by At

Am try to integrate cometd(spring-jquery-jetty7) with the appfuse spring MVC project.

my web.xml is

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/app/*</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>cometd</servlet-name>
    <servlet-class>org.cometd.server.CometdServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>cometd</servlet-name>
    <url-pattern>/cometd/*</url-pattern>
</servlet-mapping>

and did all other configuration like spring-jquery-jetty7 example, When i try cometd.handshake() from the script, it's failed and got error from the log like follows

WARN [http-8080-6] PageNotFound.handleHttpRequestMethodNotSupported(183) | Request method 'POST' not supported 115117 [http-8080-6] WARN org.springframework.web.servlet.PageNotFound - Request method POST' not supported

Anybody experience this? hope the dispatcher servlet process the request instead of cometd servlet, i dont know whats wrong in this, suggestion regarding this are welcome. thank you

1

There are 1 answers

0
mathi On

I resolve the issue by changing the servlet orders like cometd servlet first and dispatcher servlet second. The dispatcher servlet handle the cometd request first and throw the error always so i change the order like follows

 <servlet>
   <servlet-name>cometd</servlet-name>
   <servlet-class>org.cometd.server.CometdServlet</servlet-class>
   <load-on-startup>1</load-on-startup>
 </servlet>

<servlet-mapping>
   <servlet-name>cometd</servlet-name>
   <url-pattern>/cometd/*</url-pattern>
</servlet-mapping>

<servlet>
  <servlet-name>dispatcher</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
  <servlet-name>dispatcher</servlet-name>
  <url-pattern>/app/*</url-pattern>
</servlet-mapping>

and also add load-on-startup for initialize the comet servlet when application start. thank you