3 Replies Latest reply on Nov 14, 2011 5:27 PM by Venkat Sudheer Reddy Aedama

    JBoss AS 5.1.0 REST support (PUT, DELETE)?

    Farrukh Ihtisham Newbie

      Hi -

       

      I am using OData4j for my RESTful service (deployed in JBoss AS 5.1.0). When i send PUT (i.e. update request)

      and DELETE (i.e. delete request) requests from my client, I am getting this error:

       

      HTTP Status 405 - Status report. The specified HTTP method is not allowed for the requested resource (). JBoss Web/2.1.3.GA.

       

      GET and POST are working fine.

       

      I have already tried following in web.xml of my project but it does not have any impact:

       

      <security-constraint>

          <display-name>UnLock All Methods</display-name>

          <web-resource-collection>

             <web-resource-name>All Resources</web-resource-name>

             <description>Allow all web resources.</description>

             <url-pattern>/*</url-pattern>

             <http-method>GET</http-method>

             <http-method>PUT</http-method>

             <http-method>POST</http-method>

             <http-method>DELETE</http-method>

          </web-resource-collection>

      </security-constraint>

       

      Any idea about this. Is there any other setting required in JBoss AS?

       

        • 1. Re: JBoss AS 5.1.0 REST support (PUT, DELETE)?
          Venkat Sudheer Reddy Aedama Newbie

          Hello Farrukh,

           

          Just a cross-check: If you are using Jersey implementation of JAX-RS, verify if u have the following jars in the lib directory under web-inf folder?

           

          1. asm

          2. dom4j

          3. jackson-core-asl

          4. jersey-client

          5. jersey-core

          6. jersey-json

          7. jersey-server

          8. jettison

          9. jsr311

           

          Suggestion: I don't use PUT, POST, DELETE at all. I do all the operations using GET method only. That makes my coding more easy. Try changing that if it is possible.

           

          Coming to the problem, this is not JBoss AS settings problem. It seems that you don't have resources on the requested URI. Make sure that the resources are available.

           

          If your URI is pointing to a particular resource (say a database object, first go and check if it exists). DELETE operation on unavailable resource gives that 405 error.

           

          Also make sure that your database connection is NOT closed while you are calling those methods (PUT and DELETE). (You can Log the sql connection in the methods where you have your PUT and DELETE methods.)

          • 2. Re: JBoss AS 5.1.0 REST support (PUT, DELETE)?
            Mark Paluch Master

            Hi Farrukh,

            this message you get is created by your stack or let me explain it on a example:

             

            You can create a plain HttpServlet which has doPost() and doGet()-methods. Calling a POST or a GET would call these methods. When you would call DELETE or PUT it would result in the same message as you mentioned. The same applies to RESTful resources. When you have a resource annotated with @GET and an other method with @POST so GET and POST calls will go though, but only these.

             

            So you should check your REST impl, because there lies the solution. If you like, just post some code, perhaps i could help.

             

            @Venkat: Just changing the impl to use GET for updating REST resouces is not the right way.

             

            Best regards,

            Mark

            • 3. Re: JBoss AS 5.1.0 REST support (PUT, DELETE)?
              Venkat Sudheer Reddy Aedama Newbie

              Hello Mark,

              You are right. That wasn't a solution. It was just a "suggestion". It always made my coding easy. May be it's my perspective. Thanks for your ideas.

               

              Farrukh,

              If you are facing the same issue post your code snippets if you think it is okay. I suggest you to check the availability of the resources on those URIs once again.

               

              -Sudheer.