On Dec 14, 2009, at 5:55 PM, Celinio Fernandes wrote:
> I fixed it for the POST method.
> I was invoking a POST method by copy-pasting the request in the browser. That generated a GET method of course.
>
> To call the POST methods, I use an HTML page and a <form> where the action is my URL and the method is POST.
>
> I am now trying to call a PUT method using some Ajax script. Tomorrow, I'll try to copy-paste some of the code I used.
>
> But in general, what client do you use to call and test a PUT method ?
> HTML forms can only call GET and POST methods (and OPTIONS too ...) but not PUT it seems.
> Using a sniffer helped me to see what method exactly is called.
There's a neat Firefox plug-in called Poster that I've found useful.
Marc.
>
>
>
> ----- Original Message -----
> From: Paul Sandoz
> To: Celinio Fernandes
> Cc: users_at_jersey.dev.java.net
> Sent: Monday, December 14, 2009 1:52 PM
> Subject: Re: [Jersey] JBoss 5.1.0 GA + EJB 3.0: RESTful Web Services with Jersey
>
>
> On Dec 12, 2009, at 11:17 AM, Celinio Fernandes wrote:
>
>> Hi,
>> thanks Paul Sandoz.
>>
>> I am using JBoss, not GlassFish. And with Eclipse.
>> Anyways, I had a configuration problem, I needed to include the EJB project as a library in my Web project in Eclipse.
>> It is working now.
>
> OK, i am surprised such EJB support works on JBoss. I guess GlassFish and JBoss both implement the same proprietary JNDI lookup.
>
>
>>
>> However it is only working for GET HTTP methods. I have tried PUT and POST, I get the same error : 405 Method not allowed
>>
>> I have tried the most simple method ever :
>> @PUT
>> @Path("/MAJ")
>> @Consumes("text/plain")
>> public void putBlabla() {
>>
>> log.info
>> ("Body of the method);
>> }
>>
>>
>> I invoke it using the URL :
>> http://localhost:8085/MyWebApp/MAJ
>>
>> I get the error :
>> 405 Method not allowed
>>
>> how come ?
>
> How did you "invoke" it using the above URL?
>
> Paul.
>
>
>> It works with the @GET method.
>> Is there a setting to modify in JBoss AS to make it work ?
>> It does not work with @PUT, @POST ...
>>
>> Thanks for helping.
>> ----- Original Message -----
>> From: Paul Sandoz
>> To: users_at_jersey.dev.java.net
>> Cc: Celinio Fernandes
>> Sent: Friday, December 11, 2009 12:01 PM
>> Subject: Re: [Jersey] JBoss 5.1.0 GA + EJB 3.0: RESTful Web Services with Jersey
>>
>> Hi Celinio,
>>
>> It is easier to discuss in email than in blog comments :-)
>>
>> The EJB 3.0 support by annotating interfaces is not portable across app servers. When Jersey finds an interface it will attempt to look up a reference to that interface using JNDI, and that lookup is specific to GlassFish.
>>
>> If you annotate the EJB implementation they Jersey will instantiate an instance of the Java class and that instance will not be managed by the EJB container.
>>
>> Perhaps one way you can get this to work is to create your own implementation of Application:
>>
>> public class MyApplication extends javax.ws.rs.core.Application {
>> private Set<Object> singletons = new HashSet<Object>();
>>
>> public MyApplication() {
>> // Look up the EJBs references using JNDI using App server specific naming
>> // add those EJBs to the singleton set
>> }
>>
>> public Set<Object> getSingletons() {
>> return singletons;
>> }
>> }
>>
>> and register MyApplication in the web.xml.
>>
>> Paul.
>>
>>
>> On Dec 10, 2009, at 9:00 PM, Celinio Fernandes wrote:
>>
>>> Hi,
>>> I am using the Jersey implementation of the RESTful API (JSR -311) in an Enterprise application using JBoss as a server.
>>>
>>> I am using EJB 3.0 of course. Not EJB 3.1, which is still not available with JBoss.
>>>
>>> I'd like to expose a stateless session bean as a restful web service . Here is the code of its interface :
>>> import javax.ejb.Remote;
>>> import javax.ws.rs.GET;
>>> import javax.ws.rs.Path;
>>>
>>> @Path("/something")
>>> @Remote
>>> public interface blablaRemote {
>>>
>>> @GET
>>> String get();
>>>
>>> //public boolean doSomething(String one);
>>>
>>> }
>>>
>>> And the code of the bean :
>>> import javax.ejb.Stateless;
>>>
>>> @Stateless
>>> public class blablaBean implements blablaRemote {
>>>
>>> public String get() {
>>>
>>> return "HELLO FROM SESSION BEAN";
>>> }
>>>
>>> }
>>> My EJBs are located in an EJB project which is inside an Enterprise application (EAR file).
>>> How do you call that exposed resftul web service ? I do have a Web project in that Enterprise application.
>>> If using an URL, for a GET resource, what would it be like ?
>>> http://localhost/EARname/something ?
>>> http://localhost/EARname/EJBProjectName/something ?
>>> ...
>>>
>>> Thanks for helping.
>>
>>
>
>