You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Nathaniel Auvil <na...@gmail.com> on 2009/06/26 14:54:53 UTC
Trying to get a simple JAXWS-RS Service deployed to Jetty
I am trying to get my CXF application deployed to Jetty. I am trying to
also use Spring by following the Spring example although that is for a SOAP
based service. As a FYI, my code works on the internal "Server" test server
i found in the examples.
I created a beans.xml in the WEB-INF and made the
<jaxrs:server id="accountService" address="/myService">
<jaxrs:serviceBeans>
<ref bean="accountsBean" />
</jaxrs:serviceBeans>
</jaxrs:server>
<bean id="accountsBean" class="com.myCompany.ws.AccountsService" />
"address" matches the @Path("/myService") in my service implemetation.
Jetty was complaining about that before as it was teh "service1" from the
example. It seems to like that it matches now. I have a GET method on that
Class with a @Path("/accounts/{id}") and a member variable
@PathParam("id")
private Integer id;
to hold the id parameter.
I build and deploy my WAR with Maven to Jetty plugin. When i invoke the
url: http://localhost:9090/my-service/myService/accounts/19 i get the
following error: WARNING: .No root resource matching request path
/accounts/19 is found.
Can anyone help me out?
Re: Trying to get a simple JAXWS-RS Service deployed to Jetty
Posted by Sergey Beryozkin <se...@iona.com>.
Hi,
> why specify the "address" in the beans.xml Spring configuration file at
> all?
it gives extra options. For example, you may want to actually move away the
@PATH info away from the class in some cases, or at least the path fragment
which is likely to change often enough.
So suppose you have
@Path("/bar/{id}") public class Resource {}
and jaxrs:server/@address="/"
now if 'bar' may change then you'd be better off with
@Path("{id}") public class Resource {}
and jaxrs:server/@address="/bar".
AFAIK this is something one may want to do it in ServixMix which at the
moment 'enforces' a 'cxf' prefix on the endpoints...
You may also want to expose the same resource class instance in different
endpoints, say, providing different QOS to various clients :
jaxrs:server/@address="/bar"
jaxrs:server/@address="/foo"
etc
with all the endpoints reusing the same instance
hope it helps, Sergey
Nathaniel Auvil wrote:
>
> ah. that did it. Did not realize the thread safety issue. I will change
> it
> to pass id into the method.
>
> just a question....why specify the "address" in the beans.xml Spring
> configuration file at all?
>
>
> On Fri, Jun 26, 2009 at 11:52 AM, Sergey Beryozkin <
> sergey.beryozkin@iona.com> wrote:
>
>>
>> Hi
>>
>> you say that jaxrs:server/@address matches that of @Path("/myService") in
>> my
>> service implementation.
>>
>> so it should be then
>>
>> http://localhost:9090/my-service/myService/myService/accounts/19
>>
>> you can probably drop /myService from either jaxrs:address (use '/') or
>> from
>> the root resource class.
>>
>> > @PathParam("id") private Integer id;
>>
>> it would not be thread-safe unless you use a per-request resource class
>> which is instantiated on every request. At the moment we can only support
>> per-requests without Spring...
>>
>> I'll be working on making sure it works with Spring too.
>>
>> thanks, Sergey
>>
>>
>>
>> Nathaniel Auvil wrote:
>> >
>> > I am trying to get my CXF application deployed to Jetty. I am trying
>> to
>> > also use Spring by following the Spring example although that is for a
>> > SOAP
>> > based service. As a FYI, my code works on the internal "Server" test
>> > server
>> > i found in the examples.
>> >
>> >
>> > I created a beans.xml in the WEB-INF and made the
>> >
>> > <jaxrs:server id="accountService" address="/myService">
>> > <jaxrs:serviceBeans>
>> > <ref bean="accountsBean" />
>> > </jaxrs:serviceBeans>
>> > </jaxrs:server>
>> >
>> > <bean id="accountsBean" class="com.myCompany.ws.AccountsService" />
>> >
>> >
>> > "address" matches the @Path("/myService") in my service implemetation.
>> > Jetty was complaining about that before as it was teh "service1" from
>> the
>> > example. It seems to like that it matches now. I have a GET method on
>> > that
>> > Class with a @Path("/accounts/{id}") and a member variable
>> >
>> > @PathParam("id")
>> > private Integer id;
>> >
>> > to hold the id parameter.
>> >
>> > I build and deploy my WAR with Maven to Jetty plugin. When i invoke
>> the
>> > url: http://localhost:9090/my-service/myService/accounts/19 i get the
>> > following error: WARNING: .No root resource matching request path
>> > /accounts/19 is found.
>> >
>> > Can anyone help me out?
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Trying-to-get-a-simple-JAXWS-RS-Service-deployed-to-Jetty-tp24219816p24222693.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Trying-to-get-a-simple-JAXWS-RS-Service-deployed-to-Jetty-tp24219816p24224805.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Trying to get a simple JAXWS-RS Service deployed to Jetty
Posted by Nathaniel Auvil <na...@gmail.com>.
ah. that did it. Did not realize the thread safety issue. I will change it
to pass id into the method.
just a question....why specify the "address" in the beans.xml Spring
configuration file at all?
On Fri, Jun 26, 2009 at 11:52 AM, Sergey Beryozkin <
sergey.beryozkin@iona.com> wrote:
>
> Hi
>
> you say that jaxrs:server/@address matches that of @Path("/myService") in
> my
> service implementation.
>
> so it should be then
>
> http://localhost:9090/my-service/myService/myService/accounts/19
>
> you can probably drop /myService from either jaxrs:address (use '/') or
> from
> the root resource class.
>
> > @PathParam("id") private Integer id;
>
> it would not be thread-safe unless you use a per-request resource class
> which is instantiated on every request. At the moment we can only support
> per-requests without Spring...
>
> I'll be working on making sure it works with Spring too.
>
> thanks, Sergey
>
>
>
> Nathaniel Auvil wrote:
> >
> > I am trying to get my CXF application deployed to Jetty. I am trying to
> > also use Spring by following the Spring example although that is for a
> > SOAP
> > based service. As a FYI, my code works on the internal "Server" test
> > server
> > i found in the examples.
> >
> >
> > I created a beans.xml in the WEB-INF and made the
> >
> > <jaxrs:server id="accountService" address="/myService">
> > <jaxrs:serviceBeans>
> > <ref bean="accountsBean" />
> > </jaxrs:serviceBeans>
> > </jaxrs:server>
> >
> > <bean id="accountsBean" class="com.myCompany.ws.AccountsService" />
> >
> >
> > "address" matches the @Path("/myService") in my service implemetation.
> > Jetty was complaining about that before as it was teh "service1" from the
> > example. It seems to like that it matches now. I have a GET method on
> > that
> > Class with a @Path("/accounts/{id}") and a member variable
> >
> > @PathParam("id")
> > private Integer id;
> >
> > to hold the id parameter.
> >
> > I build and deploy my WAR with Maven to Jetty plugin. When i invoke the
> > url: http://localhost:9090/my-service/myService/accounts/19 i get the
> > following error: WARNING: .No root resource matching request path
> > /accounts/19 is found.
> >
> > Can anyone help me out?
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Trying-to-get-a-simple-JAXWS-RS-Service-deployed-to-Jetty-tp24219816p24222693.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>
Re: Trying to get a simple JAXWS-RS Service deployed to Jetty
Posted by Sergey Beryozkin <se...@iona.com>.
Hi
you say that jaxrs:server/@address matches that of @Path("/myService") in my
service implementation.
so it should be then
http://localhost:9090/my-service/myService/myService/accounts/19
you can probably drop /myService from either jaxrs:address (use '/') or from
the root resource class.
> @PathParam("id") private Integer id;
it would not be thread-safe unless you use a per-request resource class
which is instantiated on every request. At the moment we can only support
per-requests without Spring...
I'll be working on making sure it works with Spring too.
thanks, Sergey
Nathaniel Auvil wrote:
>
> I am trying to get my CXF application deployed to Jetty. I am trying to
> also use Spring by following the Spring example although that is for a
> SOAP
> based service. As a FYI, my code works on the internal "Server" test
> server
> i found in the examples.
>
>
> I created a beans.xml in the WEB-INF and made the
>
> <jaxrs:server id="accountService" address="/myService">
> <jaxrs:serviceBeans>
> <ref bean="accountsBean" />
> </jaxrs:serviceBeans>
> </jaxrs:server>
>
> <bean id="accountsBean" class="com.myCompany.ws.AccountsService" />
>
>
> "address" matches the @Path("/myService") in my service implemetation.
> Jetty was complaining about that before as it was teh "service1" from the
> example. It seems to like that it matches now. I have a GET method on
> that
> Class with a @Path("/accounts/{id}") and a member variable
>
> @PathParam("id")
> private Integer id;
>
> to hold the id parameter.
>
> I build and deploy my WAR with Maven to Jetty plugin. When i invoke the
> url: http://localhost:9090/my-service/myService/accounts/19 i get the
> following error: WARNING: .No root resource matching request path
> /accounts/19 is found.
>
> Can anyone help me out?
>
>
--
View this message in context: http://www.nabble.com/Trying-to-get-a-simple-JAXWS-RS-Service-deployed-to-Jetty-tp24219816p24222693.html
Sent from the cxf-user mailing list archive at Nabble.com.