You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Dante Sun <da...@gmail.com> on 2010/12/28 05:21:26 UTC

deploy multiple RESTful service bundles in FUSE ESB 4.3

I am using the example cxf-jaxrs shipped with
apache-servicemix-4.3.0-fuse-03-00.tar.gz to investigate how to deploy
multiple bundles which provides different RESTful services. What I did is
copied the cxf-jaxrs example into cxf-jaxrs-example-1, and modified the
pom.xml and beans.xml. The modifications are :

1. pom.xml
version: 4.3.0-2-fuse-03-00
name: Apache ServiceMix Example 2:: CXF JAX-RS OSGI
2. beans.xml
<jaxrs:server id="customerService2" address="/crm2">

Then I made two packages. The one is the original example package
cxf-jaxrs-4.3.0-fuse-03-00.jar and the other is the modified one
cxf-jaxrs-4.3.0-2-fuse-03-00.jar and I copied them into "deploy" directory.

After servicemix started, I see both bundles are active and started
succesfully.

But, I am only able to access the RESTful services in one bundle. When I
type "http://localhost:8080/cxf/crm2/customerservice/customers/123", I got
"No service was found." error. And when I stop the other example bundle(the
original one), I can access "
http://localhost:8080/cxf/crm2/customerservice/customers/123" with no
problems.

What I did wrong?? It is supposed to provides the RESTful services in both
context path "/crm" and "/crm2".

Re: deploy multiple RESTful service bundles in FUSE ESB 4.3

Posted by Freeman Fang <fr...@gmail.com>.
On 2010-12-28, at 下午12:21, Dante Sun wrote:

> I am using the example cxf-jaxrs shipped with
> apache-servicemix-4.3.0-fuse-03-00.tar.gz to investigate how to deploy
> multiple bundles which provides different RESTful services. What I  
> did is
> copied the cxf-jaxrs example into cxf-jaxrs-example-1, and modified  
> the
> pom.xml and beans.xml. The modifications are :
>
> 1. pom.xml
> version: 4.3.0-2-fuse-03-00
> name: Apache ServiceMix Example 2:: CXF JAX-RS OSGI
> 2. beans.xml
> <jaxrs:server id="customerService2" address="/crm2">
>
> Then I made two packages. The one is the original example package
> cxf-jaxrs-4.3.0-fuse-03-00.jar and the other is the modified one
> cxf-jaxrs-4.3.0-2-fuse-03-00.jar and I copied them into "deploy"  
> directory.
>
> After servicemix started, I see both bundles are active and started
> succesfully.
>
> But, I am only able to access the RESTful services in one bundle.  
> When I
> type "http://localhost:8080/cxf/crm2/customerservice/customers/123",  
> I got
> "No service was found." error. And when I stop the other example  
> bundle(the
> original one), I can access "
> http://localhost:8080/cxf/crm2/customerservice/customers/123" with no
> problems.
>
> What I did wrong?? It is supposed to provides the RESTful services  
> in both
> context path "/crm" and "/crm2".

Hi,

Of course it's supposed to provide different RESTful services in  
different context path.
But as your two services actually same(with same service module, which  
build from same java class CustomerService.java, so the servicename  
and port endpoint name is exactly same), I think in this case there  
should be problem when register the service/endpoint to the cxf bus.

You can try to add serviceName attribute for <jaxrs:server  
id="customerService2" address="/crm2">, to see if this helps.
Freeman


-- 
Freeman Fang

------------------------

FuseSource: http://fusesource.com
blog: http://freemanfang.blogspot.com
twitter: http://twitter.com/freemanfang
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org


Re: deploy multiple RESTful service bundles in FUSE ESB 4.3

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Dec 28, 2010 at 10:59 AM, Willem Jiang <wi...@gmail.com> wrote:
> On 12/28/10 4:38 PM, Claus Ibsen wrote:
>>
>> On Tue, Dec 28, 2010 at 7:51 AM, Willem Jiang<wi...@gmail.com>
>>  wrote:
>>>
>>> On 12/28/10 12:21 PM, Dante Sun wrote:
>>>>
>>>> I am using the example cxf-jaxrs shipped with
>>>> apache-servicemix-4.3.0-fuse-03-00.tar.gz to investigate how to deploy
>>>> multiple bundles which provides different RESTful services. What I did
>>>> is
>>>> copied the cxf-jaxrs example into cxf-jaxrs-example-1, and modified the
>>>> pom.xml and beans.xml. The modifications are :
>>>>
>>>> 1. pom.xml
>>>> version: 4.3.0-2-fuse-03-00
>>>> name: Apache ServiceMix Example 2:: CXF JAX-RS OSGI
>>>> 2. beans.xml
>>>> <jaxrs:server id="customerService2" address="/crm2">
>>>>
>>>> Then I made two packages. The one is the original example package
>>>> cxf-jaxrs-4.3.0-fuse-03-00.jar and the other is the modified one
>>>> cxf-jaxrs-4.3.0-2-fuse-03-00.jar and I copied them into "deploy"
>>>> directory.
>>>>
>>>> After servicemix started, I see both bundles are active and started
>>>> succesfully.
>>>>
>>>> But, I am only able to access the RESTful services in one bundle. When I
>>>> type "http://localhost:8080/cxf/crm2/customerservice/customers/123", I
>>>> got
>>>> "No service was found." error. And when I stop the other example
>>>> bundle(the
>>>> original one), I can access "
>>>> http://localhost:8080/cxf/crm2/customerservice/customers/123" with no
>>>> problems.
>>>>
>>>> What I did wrong?? It is supposed to provides the RESTful services in
>>>> both
>>>> context path "/crm" and "/crm2".
>>>>
>>> Please change your second context patch to "/otherCRM" which is not start
>>> with first service.
>>>
>>> For the RESTful service, CXF will pass the request which url start with
>>> "/crm" to the first service.
>>>
>>
>> This does seem like a scary bug to me.
>>
>> Its common to use xxx2, xxx3 for a simple versioning scheme to support
>> multiple versions of the "same" service.
>>
>> Why doesn't it match equals on the context path name?
>>
>>
> The user is using "crm" and "crm2".
> Just like the camel-jetty if you set matchOnUriPrefix[1] option to be true
> and start two route with this context path will make the first route take
> all the response.
>
> Using "crm1" and "crm2" are total difference use case :)
>
> [1] http://camel.apache.org/how-do-i-let-jetty-match-wildcards.html
>>

Yeah but if you do NOT use matchOnUriPrefix, eg its
matchOnUriPrefix=false (as its default).
Then I would assume you should be able to deploy 2 different REST
bundles with different context path

Such as:

/foo
/foo2

And be able to access the correct service depending on the uri hit

localhost/foo/customer/123  -> will hit REST service exposed on /foo
localhost/foo2/order/456 --> will hit REST servie exposed on /foo2





>>
>>> --
>>> Willem
>>> ----------------------------------
>>> FuseSource
>>> Web: http://www.fusesource.com
>>> Blog:    http://willemjiang.blogspot.com (English)
>>>         http://jnn.javaeye.com (Chinese)
>>> Twitter: willemjiang
>>>
>>
>>
>>
>
>
> --
> Willem
> ----------------------------------
> FuseSource
> Web: http://www.fusesource.com
> Blog:    http://willemjiang.blogspot.com (English)
>         http://jnn.javaeye.com (Chinese)
> Twitter: willemjiang
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: deploy multiple RESTful service bundles in FUSE ESB 4.3

Posted by Willem Jiang <wi...@gmail.com>.
On 12/28/10 4:38 PM, Claus Ibsen wrote:
> On Tue, Dec 28, 2010 at 7:51 AM, Willem Jiang<wi...@gmail.com>  wrote:
>> On 12/28/10 12:21 PM, Dante Sun wrote:
>>>
>>> I am using the example cxf-jaxrs shipped with
>>> apache-servicemix-4.3.0-fuse-03-00.tar.gz to investigate how to deploy
>>> multiple bundles which provides different RESTful services. What I did is
>>> copied the cxf-jaxrs example into cxf-jaxrs-example-1, and modified the
>>> pom.xml and beans.xml. The modifications are :
>>>
>>> 1. pom.xml
>>> version: 4.3.0-2-fuse-03-00
>>> name: Apache ServiceMix Example 2:: CXF JAX-RS OSGI
>>> 2. beans.xml
>>> <jaxrs:server id="customerService2" address="/crm2">
>>>
>>> Then I made two packages. The one is the original example package
>>> cxf-jaxrs-4.3.0-fuse-03-00.jar and the other is the modified one
>>> cxf-jaxrs-4.3.0-2-fuse-03-00.jar and I copied them into "deploy"
>>> directory.
>>>
>>> After servicemix started, I see both bundles are active and started
>>> succesfully.
>>>
>>> But, I am only able to access the RESTful services in one bundle. When I
>>> type "http://localhost:8080/cxf/crm2/customerservice/customers/123", I got
>>> "No service was found." error. And when I stop the other example
>>> bundle(the
>>> original one), I can access "
>>> http://localhost:8080/cxf/crm2/customerservice/customers/123" with no
>>> problems.
>>>
>>> What I did wrong?? It is supposed to provides the RESTful services in both
>>> context path "/crm" and "/crm2".
>>>
>> Please change your second context patch to "/otherCRM" which is not start
>> with first service.
>>
>> For the RESTful service, CXF will pass the request which url start with
>> "/crm" to the first service.
>>
>
> This does seem like a scary bug to me.
>
> Its common to use xxx2, xxx3 for a simple versioning scheme to support
> multiple versions of the "same" service.
>
> Why doesn't it match equals on the context path name?
>
>
The user is using "crm" and "crm2".
Just like the camel-jetty if you set matchOnUriPrefix[1] option to be 
true and start two route with this context path will make the first 
route take all the response.

Using "crm1" and "crm2" are total difference use case :)

[1] http://camel.apache.org/how-do-i-let-jetty-match-wildcards.html
>
>
>> --
>> Willem
>> ----------------------------------
>> FuseSource
>> Web: http://www.fusesource.com
>> Blog:    http://willemjiang.blogspot.com (English)
>>          http://jnn.javaeye.com (Chinese)
>> Twitter: willemjiang
>>
>
>
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Re: deploy multiple RESTful service bundles in FUSE ESB 4.3

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Dec 28, 2010 at 7:51 AM, Willem Jiang <wi...@gmail.com> wrote:
> On 12/28/10 12:21 PM, Dante Sun wrote:
>>
>> I am using the example cxf-jaxrs shipped with
>> apache-servicemix-4.3.0-fuse-03-00.tar.gz to investigate how to deploy
>> multiple bundles which provides different RESTful services. What I did is
>> copied the cxf-jaxrs example into cxf-jaxrs-example-1, and modified the
>> pom.xml and beans.xml. The modifications are :
>>
>> 1. pom.xml
>> version: 4.3.0-2-fuse-03-00
>> name: Apache ServiceMix Example 2:: CXF JAX-RS OSGI
>> 2. beans.xml
>> <jaxrs:server id="customerService2" address="/crm2">
>>
>> Then I made two packages. The one is the original example package
>> cxf-jaxrs-4.3.0-fuse-03-00.jar and the other is the modified one
>> cxf-jaxrs-4.3.0-2-fuse-03-00.jar and I copied them into "deploy"
>> directory.
>>
>> After servicemix started, I see both bundles are active and started
>> succesfully.
>>
>> But, I am only able to access the RESTful services in one bundle. When I
>> type "http://localhost:8080/cxf/crm2/customerservice/customers/123", I got
>> "No service was found." error. And when I stop the other example
>> bundle(the
>> original one), I can access "
>> http://localhost:8080/cxf/crm2/customerservice/customers/123" with no
>> problems.
>>
>> What I did wrong?? It is supposed to provides the RESTful services in both
>> context path "/crm" and "/crm2".
>>
> Please change your second context patch to "/otherCRM" which is not start
> with first service.
>
> For the RESTful service, CXF will pass the request which url start with
> "/crm" to the first service.
>

This does seem like a scary bug to me.

Its common to use xxx2, xxx3 for a simple versioning scheme to support
multiple versions of the "same" service.

Why doesn't it match equals on the context path name?




> --
> Willem
> ----------------------------------
> FuseSource
> Web: http://www.fusesource.com
> Blog:    http://willemjiang.blogspot.com (English)
>         http://jnn.javaeye.com (Chinese)
> Twitter: willemjiang
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: deploy multiple RESTful service bundles in FUSE ESB 4.3

Posted by Willem Jiang <wi...@gmail.com>.
On 12/28/10 12:21 PM, Dante Sun wrote:
> I am using the example cxf-jaxrs shipped with
> apache-servicemix-4.3.0-fuse-03-00.tar.gz to investigate how to deploy
> multiple bundles which provides different RESTful services. What I did is
> copied the cxf-jaxrs example into cxf-jaxrs-example-1, and modified the
> pom.xml and beans.xml. The modifications are :
>
> 1. pom.xml
> version: 4.3.0-2-fuse-03-00
> name: Apache ServiceMix Example 2:: CXF JAX-RS OSGI
> 2. beans.xml
> <jaxrs:server id="customerService2" address="/crm2">
>
> Then I made two packages. The one is the original example package
> cxf-jaxrs-4.3.0-fuse-03-00.jar and the other is the modified one
> cxf-jaxrs-4.3.0-2-fuse-03-00.jar and I copied them into "deploy" directory.
>
> After servicemix started, I see both bundles are active and started
> succesfully.
>
> But, I am only able to access the RESTful services in one bundle. When I
> type "http://localhost:8080/cxf/crm2/customerservice/customers/123", I got
> "No service was found." error. And when I stop the other example bundle(the
> original one), I can access "
> http://localhost:8080/cxf/crm2/customerservice/customers/123" with no
> problems.
>
> What I did wrong?? It is supposed to provides the RESTful services in both
> context path "/crm" and "/crm2".
>
Please change your second context patch to "/otherCRM" which is not 
start with first service.

For the RESTful service, CXF will pass the request which url start with 
"/crm" to the first service.

-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang