-
1. Re: [JBoss 5.1.0 GA and Jersey (REST Web Service)] GET : 405 Me
longbeach Dec 13, 2009 12:07 PM (in response to longbeach)More information regarding my previous question:
I modified the web.xml file to allow any user to call the HTTP methods but it did not change anything :
<security-constraint>
<web-resource-collection>
<web-resource-name>Ressources REST</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>OPTIONS</http-method>
<http-method>PUT</http-method>
<http-method>POST</http-method>
<http-method>TRACE</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>Any idea ? Thanks
-
2. Re: [JBoss 5.1.0 GA and Jersey (REST Web Service)] GET : 405 Me
longbeach Dec 13, 2009 3:54 PM (in response to longbeach)Well,
I have been looking everywhere, I don't have a clue.
Is this a bug in JBoss Web ?
Let me know please, thanks.
-
3. Re: [JBoss 5.1.0 GA and Jersey (REST Web Service)] GET : 405 Me
jaikiran Dec 14, 2009 1:06 AM (in response to longbeach)Is that just a 405 error message that you see in the browser? Or do you even see any exception stacktrace on the server? And what happens when you remove the security constraints on your web application? -
4. Re: [JBoss 5.1.0 GA and Jersey (REST Web Service)] GET : 405 Me
longbeach Dec 14, 2009 1:39 AM (in response to jaikiran)Thanks for helping jaikiran.
It is a 405 error message that i see in the browser. And also when using a comand line tool like CURL.
I do not see any exception stack trace in the server logs. It does not enter the method at all.
Initially i did not have any security contraints in the webapp and I had this error message already.
Any idea what's wrong ? I tried PUT, POST ... on that very simple method, it just prints a message.
And the class is a simple class. No servlet, ejb etc involved.
-
5. Re: [JBoss 5.1.0 GA and Jersey (REST Web Service)] GET : 405 Me
jaikiran Dec 14, 2009 1:58 AM (in response to longbeach)Just read one of the Jersey forum threads. Turns out, when you use that URL in the browser, it will be treated as a GET request and since your class doesn't have a @GET, it throws that method not supported error. See this http://markmail.org/thread/ycskzi3ouctkq3ik Jersey forum discussion. -
6. Re: [JBoss 5.1.0 GA and Jersey (REST Web Service)] GET : 405 Me
longbeach Dec 14, 2009 5:00 AM (in response to jaikiran)Thanks very much jaikiran pai
Your suggestion on IRC was a good one :
instead of copy-pasting the URL in the browser (or using the CURL tool), I called the URL
inside an HTML form, explicity calling the POST method (with @POST in the java method), like this :<form id="form2" action="http://localhost:8085/myWebApp/REST/MAJ" method="POST">
<input type="submit" value="Launcher POST">
</form>It works now for the POST method. However, it does not work for the PUT method though (with @PUT in the Java method):
<form id="form2" action="http://localhost:8085/myWebApp/REST/MAJ" method="PUT">
<input type="submit" value="Launcher PUT">
</form>
Why is that ? -
7. Re: [JBoss 5.1.0 GA and Jersey (REST Web Service)] GET : 405 Me
jaikiran Dec 14, 2009 6:24 AM (in response to longbeach)html "form" method attribute only supports GET and POST. So you won't be able to get PUT working with that. You might need something like the XmlHTTPRequest which you can use to to send requests to the server. See this exampe https://developer.mozilla.org/En/Using_XMLHttpRequest
-
8. Re: [JBoss 5.1.0 GA and Jersey (REST Web Service)] GET : 405 Me
longbeach Dec 15, 2009 8:28 AM (in response to jaikiran)Yes,
got it working now
I use the XMLHttpRequest object to test PUT requests.
Thanks again.