5 Replies Latest reply on Aug 24, 2016 8:02 PM by Syed Mahdi

    Getting http 405 for POST method

    Syed Mahdi Apprentice

      I am getting a 405 return code for POST request in wildfly 10 which is otherwise working on a jboss 5.0. When i deploy the same application on Wildfly, somehow Wildfly doesnt like the POST method I started logging the http requests in the unertow by using this post

       

      I started getting the http dumps like this:

       

      17:17:03,794 INFO  [io.undertow.request.dump] (default task-15)

      ----------------------------REQUEST---------------------------

                     URI=/clapp/webstart/images/orta_icon.jpg

      characterEncoding=null

           contentLength=-1

             contentType=null

                  header=Accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

                  header=Connection=keep-alive

                  header=Cache-Control=no-cache

                  header=accept-encoding=gzip

                  header=UA-Java-Version=1.8.0_91

                  header=Pragma=no-cache

                  header=User-Agent=JNLP/1.7.0 javaws/11.91.2.15 (<internal>) Java/1.8.0_91

                  header=Host=X.X.X.X:8080

                  locale=[]

                  method=GET

                protocol=HTTP/1.1

             queryString=

              remoteAddr=dever.orta.net/X.X.X.X:55550

              remoteHost=dever.orta.net

                  scheme=http

                    host=X.X.X.X:8080

              serverPort=8080

      --------------------------RESPONSE--------------------------

           contentLength=1919

             contentType=image/jpeg

                  header=Connection=keep-alive

                  header=Last-Modified=Thu, 18 Aug 2016 02:52:30 GMT

                  header=X-Powered-By=Undertow/1

                  header=Server=WildFly/10

                  header=Content-Type=image/jpeg

                  header=Content-Length=1919

                  header=Date=Mon, 22 Aug 2016 07:17:03 GMT

                  status=200

      ==============================================================

      17:17:06,927 INFO  [io.undertow.request.dump] (default I/O-11)

      ----------------------------REQUEST---------------------------

                     URI=/ortaopenint/openint

      characterEncoding=null

           contentLength=271

             contentType=[application/x-www-form-urlencoded]

                  header=Accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

                  header=Connection=keep-alive

                  header=Content-type=application/x-www-form-urlencoded

                  header=Content-Length=271

                  header=User-Agent=Java/1.8.0_91

                  header=Host=X.X.X.X:8080

                  locale=[]

                  method=POST

                protocol=HTTP/1.1

             queryString=

              remoteAddr=dever.orta.net/X.X.X.X:55550

              remoteHost=dever.orta.net

                  scheme=http

                    host=X.X.X.X:8080

              serverPort=8080

      --------------------------RESPONSE--------------------------

           contentLength=0

             contentType=null

                  header=Connection=keep-alive

                  header=X-Powered-By=Undertow/1

                  header=Server=WildFly/10

                  header=Location=http://X.X.X.X:8080/ortaopenint/openint/

                  header=Content-Length=0

                  header=Date=Mon, 22 Aug 2016 07:17:06 GMT

                  status=307

      ==============================================================

      17:17:06,929 INFO  [io.undertow.request.dump] (default task-16)

      ----------------------------REQUEST---------------------------

                     URI=/ortaopenint/openint/

      characterEncoding=null

           contentLength=271

             contentType=[application/x-www-form-urlencoded]

                  header=Accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

                  header=Connection=keep-alive

                  header=Content-type=application/x-www-form-urlencoded

                  header=Content-Length=271

                  header=User-Agent=Java/1.8.0_91

                  header=Host=X.X.X.X:8080

                  locale=[]

                  method=POST

                protocol=HTTP/1.1

             queryString=

              remoteAddr=dever.orta.net/X.X.X.X:55545

              remoteHost=dever.orta.net

                  scheme=http

                    host=X.X.X.X:8080

              serverPort=8080

      --------------------------RESPONSE--------------------------

           contentLength=104

             contentType=text/html;charset=UTF-8

                  header=Connection=keep-alive

                  header=X-Powered-By=Undertow/1

                  header=Server=WildFly/10

                  header=Content-Type=text/html;charset=UTF-8

                  header=Content-Length=104

                  header=Date=Mon, 22 Aug 2016 07:17:06 GMT

                  status=405

      ==============================================================

       

      Using this post (https://forum.camunda.org/t/enable-cors-on-wildfly/673/2) i started getting the below but it still kept on sending 405 on POST.

      ----------------------------REQUEST---------------------------

                     URI=/ortaopenint/openint

      characterEncoding=null

           contentLength=271

             contentType=[application/x-www-form-urlencoded]

                  header=Accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

                  header=Connection=keep-alive

                  header=Content-type=application/x-www-form-urlencoded

                  header=Content-Length=271

                  header=User-Agent=Java/1.8.0_91

                  header=Host=dever.orta.net:8080

                  locale=[]

                  method=POST

                protocol=HTTP/1.1

             queryString=

              remoteAddr=dever.orta.net/X.X.X.X:57843

              remoteHost=dever.orta.net

                  scheme=http

                    host=dever.orta.net:8080

              serverPort=8080

      --------------------------RESPONSE--------------------------

           contentLength=0

             contentType=null

                  header=X-Powered-By=Undertow/1

                  header=Access-Control-Allow-Headers=accept, authorization, content-type, x-requested-with

                  header=Server=WildFly/10

                  header=Location=http://dever.orta.net:8080/ortaopenint/openint/

                  header=Date=Mon, 22 Aug 2016 08:01:37 GMT

                  header=Connection=keep-alive

                  header=Access-Control-Allow-Origin=*

                  header=Access-Control-Allow-Credentials=true

                  header=Content-Length=0

                  header=Access-Control-Max-Age=1

                  header=Access-Control-Allow-Methods=GET, POST, OPTIONS, PUT

                  status=307

      ==============================================================

      18:01:37,890 DEBUG [org.jboss.weld.Reflection] (default task-7) WELD-000620: interface javax.enterprise.inject.Decorated is not declared @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation, however this may make the application unportable.

      18:01:37,891 DEBUG [org.jboss.weld.Reflection] (default task-7) WELD-000620: interface javax.enterprise.inject.Intercepted is not declared @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation, however this may make the application unportable.

      18:01:37,894 INFO  [io.undertow.request.dump] (default task-7)

      ----------------------------REQUEST---------------------------

                     URI=/ortaopenint/openint/

      characterEncoding=null

           contentLength=271

             contentType=[application/x-www-form-urlencoded]

                  header=Accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

                  header=Connection=keep-alive

                  header=Content-type=application/x-www-form-urlencoded

                  header=Content-Length=271

                  header=User-Agent=Java/1.8.0_91

                  header=Host=dever.orta.net:8080

                  locale=[]

                  method=POST

                protocol=HTTP/1.1

             queryString=

              remoteAddr=dever.orta.net/X.X.X.X:57842

              remoteHost=dever.orta.net

                  scheme=http

                    host=dever.orta.net:8080

              serverPort=8080

      --------------------------RESPONSE--------------------------

           contentLength=104

             contentType=text/html;charset=UTF-8

                  header=X-Powered-By=Undertow/1

                  header=Access-Control-Allow-Headers=accept, authorization, content-type, x-requested-with

                  header=Server=WildFly/10

                  header=Date=Mon, 22 Aug 2016 08:01:37 GMT

                  header=Connection=keep-alive

                  header=Access-Control-Allow-Origin=*

                  header=Access-Control-Allow-Credentials=true

                  header=Content-Type=text/html;charset=UTF-8

                  header=Content-Length=104

                  header=Access-Control-Max-Age=1

                  header=Access-Control-Allow-Methods=GET, POST, OPTIONS, PUT

                  status=405

      ===========================================================

       

      How can I enable POST method in wildfly. I thought the last change would actually solve this but some how it didnt. any hints or pointers will be appreciated.

       

      the actual standalone.xml config is as follows:

       

              <subsystem xmlns="urn:jboss:domain:undertow:3.0">

                  <buffer-cache name="default"/>

                  <server name="default-server">

                      <http-listener name="default" socket-binding="http" redirect-socket="https"/>

                      <host name="default-host" alias="localhost">

                          <location name="/" handler="welcome-content"/>

                          <filter-ref name="server-header"/>

                          <filter-ref name="x-powered-by-header"/>

                            <filter-ref name="request-dumper"/>

                            <filter-ref name="Access-Control-Allow-Origin"/>

                       <filter-ref name="Access-Control-Allow-Methods"/>

                       <filter-ref name="Access-Control-Allow-Headers"/>

                       <filter-ref name="Access-Control-Allow-Credentials"/>

                            <filter-ref name="Access-Control-Max-Age"/>

                      </host>

                  </server>

                  <servlet-container name="default">

                      <jsp-config/>

                      <websockets/>

                  </servlet-container>

                  <handlers>

                      <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>

                  </handlers>

                  <filters>

                      <response-header name="server-header" header-name="Server" header-value="WildFly/10"/>

                      <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>

                      <filter name="request-dumper" class-name="io.undertow.server.handlers.RequestDumpingHandler" module="io.undertow.core" />

                       <response-header name="Access-Control-Allow-Origin" header-name="Access-Control-Allow-Origin" header-value="*"/>

                       <response-header name="Access-Control-Allow-Methods" header-name="Access-Control-Allow-Methods" header-value="GET, POST, OPTIONS, PUT"/>

                       <response-header name="Access-Control-Allow-Headers" header-name="Access-Control-Allow-Headers" header-value="accept, authorization, content-type, x-requested-with"/>

                       <response-header name="Access-Control-Allow-Credentials" header-name="Access-Control-Allow-Credentials" header-value="true"/>

                       <response-header name="Access-Control-Max-Age" header-name="Access-Control-Max-Age" header-value="1"/>  

                  </filters>

              </subsystem>

       

      Message was edited by: Syed Mahdi Added the actual standalone.xml undertow config

        • 1. Re: Getting http 405 for POST method
          Tomaz Cerar Master

          how does servlet that is handling this request look like?

          • 2. Re: Getting http 405 for POST method
            Syed Mahdi Apprentice

            Thanks for your reply. really appreciate it.

             

            Technically, if i put the url in the browser it shows me the index.jsp. But a POST request is sent with I am assuming an XML message from a Jframe (swing) application it does not even reach the servlet that is on the web context, i think Wildlfy itself is just rejecting it straight out. It does not even come to the servlet. I tried debugging the servlet on the debug port but nothing gets hit and it errors out even before that.

            if you see the HTTP logs they are the undertow logs, after which the servlet log would come into play. the undertow itself is sending out the 405 in this case.

            • 3. Re: Getting http 405 for POST method
              Tomaz Cerar Master

              it is probably rejected as result of wrongly written servlet or filter that is handling that requests

              or by wrong mapping in web.xml

               

              so again, can you share how servlet / filter is written (remove bodies of methods, but just keep the main stuff in)

              and how mappings for such servlet / filter looks like in your web.xml

              • 4. Re: Getting http 405 for POST method
                Syed Mahdi Apprentice

                It might be possible, I didnt give out all the information as might convolute the problem further but here is the whole scenario and because it is working in Jboss 5.0.1 but i have seen that Jboss is very loose and Wildfly is a bit stricter and complains rightaway. I download a jnlp file from the wildfly. double clicking the jnlp, it says its downloading the application and it opens a small JframeForm with username and password field. (I also open the jconsole as  there was nothing in the widlfly logs untill i added to the undertow to dump the http requests  so now I have this in the server.log)

                 

                the servlet GenerateJnlpServlet is called here when I click on the jnlp.  I can debug the servlet and i can go through the code.

                09:39:40,704 INFO  [io.undertow.servlet] (default task-22) GenerateJnlpServlet: codeBase : http://X.X.X.X:8080/clapp/webstart/ verifyURL: none appId : none

                09:39:40,705 INFO  [io.undertow.request.dump] (default task-22)

                ----------------------------REQUEST---------------------------

                              URI=/clapp/webstart/clapp-client.jnlp

                characterEncoding=null

                    contentLength=-1

                      contentType=null

                            header=Accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

                            header=Connection=keep-alive

                            header=Cache-Control=no-cache

                            header=accept-encoding=gzip

                            header=UA-Java-Version=1.8.0_91

                            header=Pragma=no-cache

                            header=User-Agent=JNLP/1.7.0 javaws/11.91.2.15 (<internal>) Java/1.8.0_91

                            header=Host=X.X.X.X:8080

                            locale=[]

                            method=GET

                          protocol=HTTP/1.1

                      queryString=

                        remoteAddr=/X.X.X.X:51841

                        remoteHost=dever.orta.net

                            scheme=http

                              host=X.X.X.X:8080

                        serverPort=8080

                --------------------------RESPONSE--------------------------

                    contentLength=1597

                      contentType=application/x-java-jnlp-file;charset=ISO-8859-1

                            header=X-Powered-By=Undertow/1

                            header=Access-Control-Allow-Headers=accept, authorization, content-type, x-requested-with

                            header=Server=WildFly/10

                            header=Content-Disposition=inline; filename="clapp-client.jnlp"

                            header=Date=Tue, 23 Aug 2016 23:39:40 GMT

                            header=Connection=keep-alive

                            header=Access-Control-Allow-Origin=*

                            header=Access-Control-Allow-Credentials=true

                            header=Content-Type=application/x-java-jnlp-file;charset=ISO-8859-1

                            header=Content-Length=1597

                            header=Access-Control-Max-Age=1

                            header=Access-Control-Allow-Methods=GET, POST, OPTIONS, PUT

                            status=200

                ==============================================================

                09:39:40,770 INFO  [io.undertow.request.dump] (default task-23)

                ----------------------------REQUEST---------------------------

                              URI=/clapp/webstart/images/clsa_icon.gif

                characterEncoding=null

                    contentLength=-1

                      contentType=null

                            header=Accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

                            header=Cache-Control=no-cache

                            header=accept-encoding=gzip

                            header=UA-Java-Version=1.8.0_91

                            header=Pragma=no-cache

                            header=User-Agent=JNLP/1.7.0 javaws/11.91.2.15 (<internal>) Java/1.8.0_91

                            header=If-Modified-Since=Thu, 18 Aug 2016 02:52:30 GMT

                            header=Connection=keep-alive

                            header=Host=X.X.X.X:8080

                            locale=[]

                            method=GET

                          protocol=HTTP/1.1

                      queryString=

                        remoteAddr=/X.X.X.X:51843

                        remoteHost=dever.orta.net

                            scheme=http

                              host=X.X.X.X:8080

                        serverPort=8080

                --------------------------RESPONSE--------------------------

                    contentLength=-1

                      contentType=text/html;charset=UTF-8

                            header=X-Powered-By=Undertow/1

                            header=Access-Control-Allow-Headers=accept, authorization, content-type, x-requested-with

                            header=Server=WildFly/10

                            header=Date=Tue, 23 Aug 2016 23:39:40 GMT

                            header=Access-Control-Allow-Origin=*

                            header=Access-Control-Allow-Credentials=true

                            header=Content-Type=text/html;charset=UTF-8

                            header=Access-Control-Max-Age=1

                            header=Access-Control-Allow-Methods=GET, POST, OPTIONS, PUT

                            status=304

                ==============================================================

                09:39:42,604 INFO  [io.undertow.request.dump] (default task-24)

                ----------------------------REQUEST---------------------------

                              URI=/clapp/webstart/images/orta_icon.jpg

                characterEncoding=null

                    contentLength=-1

                      contentType=null

                            header=Accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

                            header=Cache-Control=no-cache

                            header=accept-encoding=gzip

                            header=UA-Java-Version=1.8.0_91

                            header=Pragma=no-cache

                            header=User-Agent=JNLP/1.7.0 javaws/11.91.2.15 (<internal>) Java/1.8.0_91

                            header=If-Modified-Since=Thu, 18 Aug 2016 02:52:30 GMT

                            header=Connection=keep-alive

                            header=Host=X.X.X.X:8080

                            locale=[]

                            method=GET

                          protocol=HTTP/1.1

                      queryString=

                        remoteAddr=dever.orta.net/X.X.X.X:51843

                        remoteHost=dever.orta.net

                            scheme=http

                              host=X.X.X.X:8080

                        serverPort=8080

                --------------------------RESPONSE--------------------------

                    contentLength=-1

                      contentType=text/html;charset=UTF-8

                            header=X-Powered-By=Undertow/1

                            header=Access-Control-Allow-Headers=accept, authorization, content-type, x-requested-with

                            header=Server=WildFly/10

                            header=Date=Tue, 23 Aug 2016 23:39:42 GMT

                            header=Access-Control-Allow-Origin=*

                            header=Access-Control-Allow-Credentials=true

                            header=Content-Type=text/html;charset=UTF-8

                            header=Access-Control-Max-Age=1

                            header=Access-Control-Allow-Methods=GET, POST, OPTIONS, PUT

                            status=304

                ==============================================================

                a small form comes up with username and password. and when i press OK it gives the 405 error and publishes this in the server.log.

                 

                 

                12:25:01,541 INFO  [io.undertow.request.dump] (default I/O-1)

                ----------------------------REQUEST---------------------------

                               URI=/ortaopenint/openint

                characterEncoding=null

                     contentLength=271

                       contentType=[application/x-www-form-urlencoded]

                            header=Accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

                            header=Connection=keep-alive

                            header=Content-type=application/x-www-form-urlencoded

                            header=Content-Length=271

                            header=User-Agent=Java/1.8.0_91

                            header=Host=dever:8080

                            locale=[]

                            method=POST

                          protocol=HTTP/1.1

                       queryString=

                        remoteAddr=/X.X.X.X:59512

                        remoteHost=dever.orta.net

                            scheme=http

                              host=dever:8080

                        serverPort=8080

                --------------------------RESPONSE--------------------------

                     contentLength=0

                       contentType=null

                            header=X-Powered-By=Undertow/1

                            header=Access-Control-Allow-Headers=accept, authorization, content-type, x-requested-with

                            header=Server=WildFly/10

                            header=Location=http://dever:8080/ortaopenint/openint/

                            header=Date=Wed, 24 Aug 2016 02:25:01 GMT

                            header=Connection=keep-alive

                            header=Access-Control-Allow-Origin=*

                            header=Access-Control-Allow-Credentials=true

                            header=Content-Length=0

                            header=Access-Control-Allow-Methods=GET, POST, OPTIONS, PUT

                            header=Access-Control-Max-Age=1

                            status=307

                ==============================================================

                12:25:01,559 INFO  [io.undertow.request.dump] (default task-11)

                ----------------------------REQUEST---------------------------

                               URI=/ortaopenint/openint/

                characterEncoding=null

                     contentLength=271

                       contentType=[application/x-www-form-urlencoded]

                            header=Accept=text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

                            header=Connection=keep-alive

                            header=Content-type=application/x-www-form-urlencoded

                            header=Content-Length=271

                            header=User-Agent=Java/1.8.0_91

                            header=Host=dever:8080

                            locale=[]

                            method=POST

                          protocol=HTTP/1.1

                       queryString=

                        remoteAddr=/X.X.X.X:59514

                        remoteHost=dever.orta.net

                            scheme=http

                              host=dever:8080

                        serverPort=8080

                --------------------------RESPONSE--------------------------

                     contentLength=104

                       contentType=text/html;charset=UTF-8

                            header=X-Powered-By=Undertow/1

                            header=Access-Control-Allow-Headers=accept, authorization, content-type, x-requested-with

                            header=Server=WildFly/10

                            header=Date=Wed, 24 Aug 2016 02:25:01 GMT

                            header=Connection=keep-alive

                            header=Access-Control-Allow-Origin=*

                            header=Access-Control-Allow-Credentials=true

                            header=Content-Type=text/html;charset=UTF-8

                            header=Content-Length=104

                            header=Access-Control-Allow-Methods=GET, POST, OPTIONS, PUT

                            header=Access-Control-Max-Age=1

                            status=405

                ==============================================================

                 

                 

                The web.xml

                <?xml version="1.0" encoding="ISO-8859-1"?>

                <!DOCTYPE web-app

                    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

                    "http://java.sun.com/dtd/web-app_2_3.dtd">

                 

                 

                <web-app>

                 

                 

                    <display-name>ChApp Services</display-name>

                 

                 

                  <context-param>

                  <param-name>contextConfigLocation</param-name>

                  <param-value>

                  classpath:conf/applicationContext-local-processors.xml,

                  classpath:conf/applicationContext-local-processors.xml,

                  classpath:conf/applicationContext-dao-hbm.xml,

                  classpath:applicationContext-services-common.xml,

                  classpath:applicationContext-services.xml,

                  classpath:services.xml

                  </param-value>

                  </context-param>

                 

                 

                  <listener>

                  <listener-class>

                  org.springframework.web.context.ContextLoaderListener

                  </listener-class>

                  </listener>

                 

                 

                  <listener>

                  <listener-class>

                  com.orta.web.AuthenticationSessionListener

                  </listener-class>

                  </listener>

                 

                    <servlet>

                        <servlet-name>OrtaXmlServlet</servlet-name>

                        <servlet-class>com.orta.web.CSAFExtXmlServlet</servlet-class>

                    </servlet>

                 

                 

                    <servlet-mapping>

                        <servlet-name>OrtaXmlServlet</servlet-name>

                        <url-pattern>/openint</url-pattern>

                <!-- also tried:

                          <url-pattern>/ortaopenint/openint</url-pattern>     -->

                    </servlet-mapping>

                 

                 

                    <session-config>

                        <session-timeout>30</session-timeout>

                    </session-config>

                 

                 

                </web-app>

                now the servlet that is bound by /openint context is :

                public abstract class AbstractServlet extends HttpServlet {

                 

                 

                public void doGet(HttpServletRequest request, HttpServletResponse response)

                            throws IOException, ServletException {

                        doGetOrPost(request, response);

                    }

                 

                 

                    public void doPost(HttpServletRequest request, HttpServletResponse response)

                            throws IOException, ServletException {

                        doGetOrPost(request, response); // the breakpoint never comes here.

                    }

                 

                 

                    abstract protected void doGetOrPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException;

                  The extended class

                 

                public class OrtaXmlServlet extends AbstractServlet {

                    private static final long serialVersionUID = 1L;

                    protected Logger log = Logger.getLogger(OrtaXmlServlet.class);

                 

                  private WebApplicationContext context;

                  private OpenintPreferenceService txPrefService;

                 

                 

                    /**

                  * @see javax.servlet.GenericServlet#init()

                  */

                  public void init() throws ServletException {

                // it never comes here either.

                  }

                 

                // Previously the service method had the same method body as doGetOrPost but then looking at    http://stackoverflow.com/questions/13891975/overriding-httpservlet-service-method

                //  it seemed obvious that this might be the issue and I followed the solution above. Thinking that this will cause the doPost method to be run but this did notsolve the case. I have still changed the code to implement the  doGetOrPost

                // protected void service(HttpServletRequest request,

                //                           HttpServletResponse response)

                //            throws ServletException, IOException {

                //  All the stuff here moved down to doGetOrPost

                //

                //    }

                 

                 

                    protected boolean validateSession(String packageId, String requestType, String vendorId, HttpServletRequest request, HttpServletResponse response) throws IOException {

                 

                 

                        return true;

                    }

                 

                 

                    protected Document processOtherRequestTypes(String packageId, String requestType, String vendorId, Element messageElement, Document requestDocument, HttpServletRequest request, HttpServletResponse response) throws IOException {

                 

                 

                        return responseDoc;

                    }

                 

                 

                    @Override

                    protected void doGetOrPost(HttpServletRequest request, HttpServletResponse response)

                            throws ServletException, IOException  {

                  //it never comes to any breakpoint in here

                // it has all the logic to process all the requests that we think will come in.

                 

                 

                }

                // this class is actually bound to the /openint web context.

                public class CSAFExtXmlServlet extends OrtaXmlServlet {

                 

                 

                  protected Document processOtherRequestTypes(String packageId, String requestType, String vendorId, Element messageElement, Document requestDocument, HttpServletRequest request, HttpServletResponse response) throws IOException {

                 

                  }

                 

                 

                  protected boolean validateSession(String packageId, String requestType, String vendorId, HttpServletRequest request, HttpServletResponse response) throws IOException {

                 

                  return true;

                  }

                }

                 

                Stuart gave the solution on this question but i cant seem to understand how to do that.HTTP method POST is not supported by this URL

                 

                I changed the OrtaXmlServlet  when you said that perhaps the servlet is not written properly So i looked at http://stackoverflow.com/questions/13891975/overriding-httpservlet-service-method and i went in and replaced the service method with doGetOrPost as it said that the service method shouldnt be overridden. previously all the logic was in the overridden service method. but even after commenting out the overridden service method and creating the doGetorPost(), it did not work. I was very much confident that now that I have given the doPost its implementation back as the overriding service() method was not handling the POST requests it should have worked. but now I am back to my original conclusion that Wildfly's Undertow is itself not letting it even reach the servlet.

                 

                As for the service() method. i think that implementation was not correct either so i am going to keep the doGetorPost method. even though it does not solve the problem of 405 sadly.

                 

                EDIT: one more reason why i think its not the servlet yet because on the Jconsole that i mentioned above. I try to do this and it errors out on this bit of code:

                 

                java.io.IOException: Server returned HTTP response code: 405 for URL: http://dever:8080/ortaopenint/openint/

                  at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)

                  at sun.net.www.protocol.http.HttpURLConnection.access$200(Unknown Source)

                  at sun.net.www.protocol.http.HttpURLConnection$9.run(Unknown Source)

                  at sun.net.www.protocol.http.HttpURLConnection$9.run(Unknown Source)

                  at java.security.AccessController.doPrivileged(Native Method)

                  at java.security.AccessController.doPrivilegedWithCombiner(Unknown Source)

                  at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)

                  at com.orta.data.XMLRequest.sendXml(XMLRequest.java:612)

                  at com.orta.data.XMLRequest.sendStart(XMLRequest.java:722)

                  at com.orta.data.XMLRequestWorker.construct(XMLRequestWorker.java:75)

                  at com.orta.swing.SwingWorker$2.run(SwingWorker.java:155)

                  at java.lang.Thread.run(Unknown Source)

                This piece of code comes from the :

                 

                 

                protected final Document sendXml(Document request) throws InterruptedException {

                      

                  HttpURLConnection httpConn = null;

                  try {

                  // Connect to the requestURL

                  URLConnection conn = reqUtil.getRequestURL().openConnection();

                  httpConn = (HttpURLConnection)conn;

                  httpConn.setDoOutput(true);

                            String sessionId = null;

                          

                            Node rootNode = request.getFirstChild();

                            NodeList childNodes = rootNode.getChildNodes();

                            for (int i = 0; i < childNodes.getLength(); i++) {

                                Node child = childNodes.item(i);

                                if (child.getNodeType() == Node.ELEMENT_NODE && "Authentication".equals(child.getNodeName())) {

                                    NodeList authNodes = child.getChildNodes();

                                  

                                    for (int j = 0; j < authNodes.getLength(); j++) {

                                        Node authChild = authNodes.item(j);

                                        if (authChild.getNodeType() == Node.ELEMENT_NODE && "Credential".equals(authChild.getNodeName())) {

                                            if (authChild.getFirstChild() != null) {

                                                sessionId = authChild.getFirstChild().getNodeValue();

                                            }

                                        }

                                    }

                                }

                            }

                          

                            // Reassociate with our old session if possible

                            if (sessionId != null && sessionId.length() > 0) {

                                httpConn.setRequestProperty("cookie", "JSESSIONID=" + sessionId);

                            }

                  httpConn.connect(); / either it is here that it gets 405 as the line number matches here

                          

                  // Get the connection OutputStream

                  OutputStream outStream = httpConn.getOutputStream();

                          

                  try {

                  XmlTool.DomToXml(request, outStream, true);

                  } catch (XmlException e) {

                  e.printStackTrace();

                  throw new RuntimeException(e);

                  }

                          

                  // Get the connection InputStream

                  InputStream inStream = httpConn.getInputStream(); // Or it is here where it gets the 405 error

                If you see code above it has only trying to make an http connection and this is from the GUI component that has the Jframe which basically tries to send the request but on order to do that it tries to (either) connect /(or) tries to get InputStream. If we say that it is the getInputStream toget the response and this is the response coming from the servlet, then i am not able to get anybreakpoints hit. I can add some logging to see if it is being triggered which I will try now and see if that gives me something.

                EDIT: i added some log statements and they didnt log meaning I am not even getting into the init of the servlet OrtaXmlServlet.

                Thanks for your reply and sorry for the length of the post. I hope you can help.

                • 5. Re: Getting http 405 for POST method
                  Syed Mahdi Apprentice

                  I found the cause. The web-context wsa defined in two places. Half of it was defined in the pom file in the definition of the webmodule for the ear plugin and half of it was defined in web.xml. even though i was going to the right url, the servlet was mapped to /ortaopenint/openint/openint/ . i kept on changing the one in the web.xml. In any case the error was very misleading. a 404 servlet not found would have been more appropriate i think. At least my issue is solved.

                  I really appreciate your help Tomaz. I did however found a bug in our servlet (overriding the service() method)