JAXRS: Multiple service beans problem

View: New views
12 Messages — Rating Filter:   Alert me  

JAXRS: Multiple service beans problem

by arimus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am having an issue mapping multiple service beans. Only the first bean's
paths seem to be mapped at all.  So something like this would not work for
me, because only authenticate service methods would be available:

  <jaxrs:server id="serviceServer" address="/">
    <jaxrs:serviceBeans>
      <ref bean="authServiceImpl" />
      <ref bean="contactServiceImpl" />
    </jaxrs:serviceBeans>

*Here are the service interfaces:*

public interface AuthenticationService {
    @GET
    @Path("/authenticate/{uid}:{pass}")
    public Response authenticate(@PathParam("uid") String username,
@PathParam("pass") String password);
}

public interface ContactService {
    @GET
    @Path("/contacts")
    public Contacts getContacts();
}

I can't find a solution to this other than creating an uber service
interface that extended all the other interfaces...or potentially creating
new jaxrs:server entries for each and every service.  Thoughts, suggestions?

Not sure if it is related, but also ran into a similar problem, where when I
have two service interfaces like below...where service A and B both have a
common sub-path.  It seems that both /v3/authenticate and /v4/authenticate
are available.  However, /v4/authenticate/validate is not available.  No
sub-path for a method is available in v4 if v3 doesn't have the same path.
If I remove the v3 bean, then both v4 methods are available.

*Take the following from cxf_beans.xml where I define 2 service beans:*

  <jaxrs:server id="serviceServer" address="/">
    <jaxrs:serviceBeans>
      <ref bean="contactServiceImpl3" />
      <ref bean="contactServiceImpl4" />
    </jaxrs:serviceBeans>

*Here are the service interfaces:*

=====

@Path("/v3")
public interface AuthenticationService {
    @GET
    @Path("/authenticate/{uid}:{pass}")
    public Response authenticate(@PathParam("uid") String username,
@PathParam("pass") String password);
}

=====

@Path("/v4")
public interface AuthenticationService {
    @GET
    @Path("/authenticate/{uid}:{pass}")
    public Response authenticate(@PathParam("uid") String username,
@PathParam("pass") String password);

    @GET
    @Path("/authenticate/validate/{token}")
    public Response validate(@PathParam("token") String token);
}

=====


*The error in the logs:*

2009-04-15 22:39:51,028 ERROR [STDERR] Apr 15, 2009 10:39:51 PM
org.apache.cxf.jaxrs.utils.JAXRSUtils findTargetMethod
WARNING: .No operation matching request path
/authenticate/validate/BTaaZUycRa is found, ContentType : */*, Accept :
application/xml

Re: JAXRS: Multiple service beans problem

by arimus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Interesting, I found a similar problem on the lists just now, but no
resolution...

http://www.mail-archive.com/users@.../msg03977.html

On Wed, Apr 15, 2009 at 4:31 PM, David Castro <apudcastro@...>wrote:

> I am having an issue mapping multiple service beans. Only the first bean's
> paths seem to be mapped at all.  So something like this would not work for
> me, because only authenticate service methods would be available:
>
>   <jaxrs:server id="serviceServer" address="/">
>     <jaxrs:serviceBeans>
>       <ref bean="authServiceImpl" />
>       <ref bean="contactServiceImpl" />
>     </jaxrs:serviceBeans>
>
> *Here are the service interfaces:*
>
> public interface AuthenticationService {
>     @GET
>     @Path("/authenticate/{uid}:{pass}")
>     public Response authenticate(@PathParam("uid") String username,
> @PathParam("pass") String password);
> }
>
> public interface ContactService {
>     @GET
>     @Path("/contacts")
>     public Contacts getContacts();
> }
>
> I can't find a solution to this other than creating an uber service
> interface that extended all the other interfaces...or potentially creating
> new jaxrs:server entries for each and every service.  Thoughts, suggestions?
>
> Not sure if it is related, but also ran into a similar problem, where when
> I have two service interfaces like below...where service A and B both have a
> common sub-path.  It seems that both /v3/authenticate and /v4/authenticate
> are available.  However, /v4/authenticate/validate is not available.  No
> sub-path for a method is available in v4 if v3 doesn't have the same path.
> If I remove the v3 bean, then both v4 methods are available.
>
> *Take the following from cxf_beans.xml where I define 2 service beans:*
>
>   <jaxrs:server id="serviceServer" address="/">
>     <jaxrs:serviceBeans>
>       <ref bean="contactServiceImpl3" />
>       <ref bean="contactServiceImpl4" />
>     </jaxrs:serviceBeans>
>
> *Here are the service interfaces:*
>
> =====
>
> @Path("/v3")
> public interface AuthenticationService {
>     @GET
>     @Path("/authenticate/{uid}:{pass}")
>     public Response authenticate(@PathParam("uid") String username,
> @PathParam("pass") String password);
> }
>
> =====
>
> @Path("/v4")
> public interface AuthenticationService {
>     @GET
>     @Path("/authenticate/{uid}:{pass}")
>     public Response authenticate(@PathParam("uid") String username,
> @PathParam("pass") String password);
>
>     @GET
>     @Path("/authenticate/validate/{token}")
>     public Response validate(@PathParam("token") String token);
> }
>
> =====
>
>
> *The error in the logs:*
>
> 2009-04-15 22:39:51,028 ERROR [STDERR] Apr 15, 2009 10:39:51 PM
> org.apache.cxf.jaxrs.utils.JAXRSUtils findTargetMethod
> WARNING: .No operation matching request path
> /authenticate/validate/BTaaZUycRa is found, ContentType : */*, Accept :
> application/xml
>

Re: JAXRS: Multiple service beans problem

by arimus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Have my own little conversation going here now ;)   So looking deeper at
that other post, apparently you need to have a unique root path name for
each service class for the matching to work right now.  Kind of a bummer
that you can't have multiple classes with / for a root path and just have
CXF search all / path classes for particular sub-resource locators. But at
least I know how to get around the issue there.

On Wed, Apr 15, 2009 at 4:51 PM, David Castro <apudcastro@...>wrote:

> Interesting, I found a similar problem on the lists just now, but no
> resolution...
>
> http://www.mail-archive.com/users@.../msg03977.html
>
>
> On Wed, Apr 15, 2009 at 4:31 PM, David Castro <apudcastro@...>wrote:
>
>> I am having an issue mapping multiple service beans. Only the first bean's
>> paths seem to be mapped at all.  So something like this would not work for
>> me, because only authenticate service methods would be available:
>>
>>   <jaxrs:server id="serviceServer" address="/">
>>     <jaxrs:serviceBeans>
>>       <ref bean="authServiceImpl" />
>>       <ref bean="contactServiceImpl" />
>>     </jaxrs:serviceBeans>
>>
>> *Here are the service interfaces:*
>>
>> public interface AuthenticationService {
>>     @GET
>>     @Path("/authenticate/{uid}:{pass}")
>>     public Response authenticate(@PathParam("uid") String username,
>> @PathParam("pass") String password);
>> }
>>
>> public interface ContactService {
>>     @GET
>>     @Path("/contacts")
>>     public Contacts getContacts();
>> }
>>
>> I can't find a solution to this other than creating an uber service
>> interface that extended all the other interfaces...or potentially creating
>> new jaxrs:server entries for each and every service.  Thoughts, suggestions?
>>
>> Not sure if it is related, but also ran into a similar problem, where when
>> I have two service interfaces like below...where service A and B both have a
>> common sub-path.  It seems that both /v3/authenticate and /v4/authenticate
>> are available.  However, /v4/authenticate/validate is not available.  No
>> sub-path for a method is available in v4 if v3 doesn't have the same path.
>> If I remove the v3 bean, then both v4 methods are available.
>>
>> *Take the following from cxf_beans.xml where I define 2 service beans:*
>>
>>   <jaxrs:server id="serviceServer" address="/">
>>     <jaxrs:serviceBeans>
>>       <ref bean="contactServiceImpl3" />
>>       <ref bean="contactServiceImpl4" />
>>     </jaxrs:serviceBeans>
>>
>> *Here are the service interfaces:*
>>
>> =====
>>
>> @Path("/v3")
>> public interface AuthenticationService {
>>     @GET
>>     @Path("/authenticate/{uid}:{pass}")
>>     public Response authenticate(@PathParam("uid") String username,
>> @PathParam("pass") String password);
>> }
>>
>> =====
>>
>> @Path("/v4")
>> public interface AuthenticationService {
>>     @GET
>>     @Path("/authenticate/{uid}:{pass}")
>>     public Response authenticate(@PathParam("uid") String username,
>> @PathParam("pass") String password);
>>
>>     @GET
>>     @Path("/authenticate/validate/{token}")
>>     public Response validate(@PathParam("token") String token);
>> }
>>
>> =====
>>
>>
>> *The error in the logs:*
>>
>> 2009-04-15 22:39:51,028 ERROR [STDERR] Apr 15, 2009 10:39:51 PM
>> org.apache.cxf.jaxrs.utils.JAXRSUtils findTargetMethod
>> WARNING: .No operation matching request path
>> /authenticate/validate/BTaaZUycRa is found, ContentType : */*, Accept :
>> application/xml
>>
>
>

Re: JAXRS: Multiple service beans problem

by Sergey Beryozkin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

It's just a JAXRS selection algorithm that dictates it, or rather, it does not allow for selecting between multiple resource classes
which have the same Path value. Perhaps you may want to consider using Path values with custom regular expressions rather than
hardcoding unique values into each root class's Path values.
I kind of like the idea of trying another resource class if the initially taken route through the initially chosen root class
produces no valid operation - I'll add it to the list...

Can you explain a bit more please about this issue :

>>> Not sure if it is related, but also ran into a similar problem, where when
>>> I have two service interfaces like below...where service A and B both have a
>>> common sub-path.  It seems that both /v3/authenticate and /v4/authenticate
>>> are available.  However, /v4/authenticate/validate is not available.  No
>>> sub-path for a method is available in v4 if v3 doesn't have the same path.
>>> If I remove the v3 bean, then both v4 methods are available.
>>>
>>> *Take the following from cxf_beans.xml where I define 2 service beans:*
>>>
>>>   <jaxrs:server id="serviceServer" address="/">
>>>     <jaxrs:serviceBeans>
>>>       <ref bean="contactServiceImpl3" />
>>>       <ref bean="contactServiceImpl4" />
>>>     </jaxrs:serviceBeans>
>>>
>>> *Here are the service interfaces:*
>>>
>>> =====
>>>
>>> @Path("/v3")
>>> public interface AuthenticationService {
>>>     @GET
>>>     @Path("/authenticate/{uid}:{pass}")
>>>     public Response authenticate(@PathParam("uid") String username,
>>> @PathParam("pass") String password);
>>> }
>>>
>>> =====
>>>
>>> @Path("/v4")
>>> public interface AuthenticationService {
>>>     @GET
>>>     @Path("/authenticate/{uid}:{pass}")
>>>     public Response authenticate(@PathParam("uid") String username,
>>> @PathParam("pass") String password);
>>>
>>>     @GET
>>>     @Path("/authenticate/validate/{token}")
>>>     public Response validate(@PathParam("token") String token);
>>> }
>>>
>>> =====

I'm presuming those 2 AuthenticationService(s) are in different packages ?

So if you do "/v4/authenticate/validate/BTaaZUycRa" then no operation can be found unless you remove a bean which implements
AuthenticationService with /v3 ?


cheers, Sergey

----- Original Message -----
From: "David Castro" <apudcastro@...>
To: <users@...>
Sent: Thursday, April 16, 2009 1:59 AM
Subject: Re: JAXRS: Multiple service beans problem


> Have my own little conversation going here now ;)   So looking deeper at
> that other post, apparently you need to have a unique root path name for
> each service class for the matching to work right now.  Kind of a bummer
> that you can't have multiple classes with / for a root path and just have
> CXF search all / path classes for particular sub-resource locators. But at
> least I know how to get around the issue there.
>


Re: JAXRS: Multiple service beans problem

by arimus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Apr 16, 2009 at 2:40 AM, Sergey Beryozkin <sberyozk@...>wrote:

> Hi
>
> It's just a JAXRS selection algorithm that dictates it, or rather, it does
> not allow for selecting between multiple resource classes which have the
> same Path value. Perhaps you may want to consider using Path values with
> custom regular expressions rather than hardcoding unique values into each
> root class's Path values.
> I kind of like the idea of trying another resource class if the initially
> taken route through the initially chosen root class produces no valid
> operation - I'll add it to the list...
>

Regexes...didn't know that was possible!  That's good to know, thanks.


>
> Can you explain a bit more please about this issue :
>
>
>  Not sure if it is related, but also ran into a similar problem, where when
>>>> I have two service interfaces like below...where service A and B both
>>>> have a
>>>> common sub-path.  It seems that both /v3/authenticate and
>>>> /v4/authenticate
>>>> are available.  However, /v4/authenticate/validate is not available.  No
>>>> sub-path for a method is available in v4 if v3 doesn't have the same
>>>> path.
>>>> If I remove the v3 bean, then both v4 methods are available.
>>>>
>>>> *Take the following from cxf_beans.xml where I define 2 service beans:*
>>>>
>>>>  <jaxrs:server id="serviceServer" address="/">
>>>>    <jaxrs:serviceBeans>
>>>>      <ref bean="contactServiceImpl3" />
>>>>      <ref bean="contactServiceImpl4" />
>>>>    </jaxrs:serviceBeans>
>>>>
>>>> *Here are the service interfaces:*
>>>>
>>>> =====
>>>>
>>>> @Path("/v3")
>>>> public interface AuthenticationService {
>>>>    @GET
>>>>    @Path("/authenticate/{uid}:{pass}")
>>>>    public Response authenticate(@PathParam("uid") String username,
>>>> @PathParam("pass") String password);
>>>> }
>>>>
>>>> =====
>>>>
>>>> @Path("/v4")
>>>> public interface AuthenticationService {
>>>>    @GET
>>>>    @Path("/authenticate/{uid}:{pass}")
>>>>    public Response authenticate(@PathParam("uid") String username,
>>>> @PathParam("pass") String password);
>>>>
>>>>    @GET
>>>>    @Path("/authenticate/validate/{token}")
>>>>    public Response validate(@PathParam("token") String token);
>>>> }
>>>>
>>>> =====
>>>>
>>>
> I'm presuming those 2 AuthenticationService(s) are in different packages ?
>

Yes, two separate interfaces.  They just happen to share common sub-locator
paths.


>
> So if you do "/v4/authenticate/validate/BTaaZUycRa" then no operation can
> be found unless you remove a bean which implements
> AuthenticationService with /v3 ?
>

Correct.  The validate is hidden until the the v3 bean is removed.  But
authenticate method works fine on both, presumable because it exists in
both.


>
>
> cheers, Sergey
>
> ----- Original Message ----- From: "David Castro" <apudcastro@...>
> To: <users@...>
> Sent: Thursday, April 16, 2009 1:59 AM
> Subject: Re: JAXRS: Multiple service beans problem
>
>
>
>  Have my own little conversation going here now ;)   So looking deeper at
>> that other post, apparently you need to have a unique root path name for
>> each service class for the matching to work right now.  Kind of a bummer
>> that you can't have multiple classes with / for a root path and just have
>> CXF search all / path classes for particular sub-resource locators. But at
>> least I know how to get around the issue there.
>>
>>
>

Re: JAXRS: Multiple service beans problem

by Sergey Beryozkin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi David

I need a little bit more help.
Lets say you have some root resource class with the following locator method :

@Path("/")
public class RootResourceClass {

     @Path("/service/{version}")
     Object getAuthenticationService(int version) {
          return version == 3 ? new  org.foo.bar.v3.AuthenticateServiceImpl() : org.foo.bar.v4.AuthenticateServiceImpl() ;
     }

}

You said both AuthenticateService implementations share the common sublocator path, so does the above sample is close enough to the
way you do it in the actual code ?

Can you please post a sample root resource class showing how AuthenticateService instances are returned ?

Thanks, Sergey

>>>>> *Here are the service interfaces:*
>>>>>
>>>>> =====
>>>>>
>>>>> @Path("/v3")
>>>>> public interface AuthenticationService {
>>>>>    @GET
>>>>>    @Path("/authenticate/{uid}:{pass}")
>>>>>    public Response authenticate(@PathParam("uid") String username,
>>>>> @PathParam("pass") String password);
>>>>> }
>>>>>
>>>>> =====
>>>>>
>>>>> @Path("/v4")
>>>>> public interface AuthenticationService {
>>>>>    @GET
>>>>>    @Path("/authenticate/{uid}:{pass}")
>>>>>    public Response authenticate(@PathParam("uid") String username,
>>>>> @PathParam("pass") String password);
>>>>>
>>>>>    @GET
>>>>>    @Path("/authenticate/validate/{token}")
>>>>>    public Response validate(@PathParam("token") String token);
>>>>> }
>>>>>
>>>>> =====
>>>>>
>>>>
>> I'm presuming those 2 AuthenticationService(s) are in different packages ?
>>
>
> Yes, two separate interfaces.  They just happen to share common sub-locator
> paths.
>
>
>>
>> So if you do "/v4/authenticate/validate/BTaaZUycRa" then no operation can
>> be found unless you remove a bean which implements
>> AuthenticationService with /v3 ?
>>
>
> Correct.  The validate is hidden until the the v3 bean is removed.  But
> authenticate method works fine on both, presumable because it exists in
> both.
>


Re: JAXRS: Multiple service beans problem

by Kynan Fraser :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Sergey,

Was there a JIRA issue opened for this or has it been added as a feature?

Regards,
Kynan

Sergey Beryozkin-2 wrote:
Hi

It's just a JAXRS selection algorithm that dictates it, or rather, it does not allow for selecting between multiple resource classes
which have the same Path value. Perhaps you may want to consider using Path values with custom regular expressions rather than
hardcoding unique values into each root class's Path values.
I kind of like the idea of trying another resource class if the initially taken route through the initially chosen root class
produces no valid operation - I'll add it to the list...

Can you explain a bit more please about this issue :

>>> Not sure if it is related, but also ran into a similar problem, where when
>>> I have two service interfaces like below...where service A and B both have a
>>> common sub-path.  It seems that both /v3/authenticate and /v4/authenticate
>>> are available.  However, /v4/authenticate/validate is not available.  No
>>> sub-path for a method is available in v4 if v3 doesn't have the same path.
>>> If I remove the v3 bean, then both v4 methods are available.
>>>
>>> *Take the following from cxf_beans.xml where I define 2 service beans:*
>>>
>>>   <jaxrs:server id="serviceServer" address="/">
>>>     <jaxrs:serviceBeans>
>>>       <ref bean="contactServiceImpl3" />
>>>       <ref bean="contactServiceImpl4" />
>>>     </jaxrs:serviceBeans>
>>>
>>> *Here are the service interfaces:*
>>>
>>> =====
>>>
>>> @Path("/v3")
>>> public interface AuthenticationService {
>>>     @GET
>>>     @Path("/authenticate/{uid}:{pass}")
>>>     public Response authenticate(@PathParam("uid") String username,
>>> @PathParam("pass") String password);
>>> }
>>>
>>> =====
>>>
>>> @Path("/v4")
>>> public interface AuthenticationService {
>>>     @GET
>>>     @Path("/authenticate/{uid}:{pass}")
>>>     public Response authenticate(@PathParam("uid") String username,
>>> @PathParam("pass") String password);
>>>
>>>     @GET
>>>     @Path("/authenticate/validate/{token}")
>>>     public Response validate(@PathParam("token") String token);
>>> }
>>>
>>> =====

I'm presuming those 2 AuthenticationService(s) are in different packages ?

So if you do "/v4/authenticate/validate/BTaaZUycRa" then no operation can be found unless you remove a bean which implements
AuthenticationService with /v3 ?


cheers, Sergey

----- Original Message -----
From: "David Castro" <apudcastro@entwash.org>
To: <users@cxf.apache.org>
Sent: Thursday, April 16, 2009 1:59 AM
Subject: Re: JAXRS: Multiple service beans problem


> Have my own little conversation going here now ;)   So looking deeper at
> that other post, apparently you need to have a unique root path name for
> each service class for the matching to work right now.  Kind of a bummer
> that you can't have multiple classes with / for a root path and just have
> CXF search all / path classes for particular sub-resource locators. But at
> least I know how to get around the issue there.
>

Re: JAXRS: Multiple service beans problem

by Sergey Beryozkin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Kynan

No, not yet. Please open the JIRA for it (make it 'Fix for 2.3')

thanks, Sergey


Hi Sergey,

Was there a JIRA issue opened for this or has it been added as a feature?

Regards,
Kynan

Sergey Beryozkin-2 wrote:
Hi

It's just a JAXRS selection algorithm that dictates it, or rather, it does not allow for selecting between multiple resource classes
which have the same Path value. Perhaps you may want to consider using Path values with custom regular expressions rather than
hardcoding unique values into each root class's Path values.
I kind of like the idea of trying another resource class if the initially taken route through the initially chosen root class
produces no valid operation - I'll add it to the list...

Can you explain a bit more please about this issue :

>>> Not sure if it is related, but also ran into a similar problem, where when
>>> I have two service interfaces like below...where service A and B both have a
>>> common sub-path.  It seems that both /v3/authenticate and /v4/authenticate
>>> are available.  However, /v4/authenticate/validate is not available.  No
>>> sub-path for a method is available in v4 if v3 doesn't have the same path.
>>> If I remove the v3 bean, then both v4 methods are available.
>>>
>>> *Take the following from cxf_beans.xml where I define 2 service beans:*
>>>
>>>   <jaxrs:server id="serviceServer" address="/">
>>>     <jaxrs:serviceBeans>
>>>       <ref bean="contactServiceImpl3" />
>>>       <ref bean="contactServiceImpl4" />
>>>     </jaxrs:serviceBeans>
>>>
>>> *Here are the service interfaces:*
>>>
>>> =====
>>>
>>> @Path("/v3")
>>> public interface AuthenticationService {
>>>     @GET
>>>     @Path("/authenticate/{uid}:{pass}")
>>>     public Response authenticate(@PathParam("uid") String username,
>>> @PathParam("pass") String password);
>>> }
>>>
>>> =====
>>>
>>> @Path("/v4")
>>> public interface AuthenticationService {
>>>     @GET
>>>     @Path("/authenticate/{uid}:{pass}")
>>>     public Response authenticate(@PathParam("uid") String username,
>>> @PathParam("pass") String password);
>>>
>>>     @GET
>>>     @Path("/authenticate/validate/{token}")
>>>     public Response validate(@PathParam("token") String token);
>>> }
>>>
>>> =====

I'm presuming those 2 AuthenticationService(s) are in different packages ?

So if you do "/v4/authenticate/validate/BTaaZUycRa" then no operation can be found unless you remove a bean which implements
AuthenticationService with /v3 ?


cheers, Sergey

----- Original Message -----
From: "David Castro" <apudcastro@entwash.org>
To: <users@cxf.apache.org>
Sent: Thursday, April 16, 2009 1:59 AM
Subject: Re: JAXRS: Multiple service beans problem


> Have my own little conversation going here now ;)   So looking deeper at
> that other post, apparently you need to have a unique root path name for
> each service class for the matching to work right now.  Kind of a bummer
> that you can't have multiple classes with / for a root path and just have
> CXF search all / path classes for particular sub-resource locators. But at
> least I know how to get around the issue there.
>


Re: JAXRS: Multiple service beans problem

by Kynan Fraser :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Done: https://issues.apache.org/jira/browse/CXF-2439


Hi Kynan

No, not yet. Please open the JIRA for it (make it 'Fix for 2.3')

thanks, Sergey

Kynan Fraser wrote:
Hi Sergey,

Was there a JIRA issue opened for this or has it been added as a feature?

Regards,
Kynan

Sergey Beryozkin-2 wrote:
Hi

It's just a JAXRS selection algorithm that dictates it, or rather, it does not allow for selecting between multiple resource classes
which have the same Path value. Perhaps you may want to consider using Path values with custom regular expressions rather than
hardcoding unique values into each root class's Path values.
I kind of like the idea of trying another resource class if the initially taken route through the initially chosen root class
produces no valid operation - I'll add it to the list...

Can you explain a bit more please about this issue :

>>> Not sure if it is related, but also ran into a similar problem, where when
>>> I have two service interfaces like below...where service A and B both have a
>>> common sub-path.  It seems that both /v3/authenticate and /v4/authenticate
>>> are available.  However, /v4/authenticate/validate is not available.  No
>>> sub-path for a method is available in v4 if v3 doesn't have the same path.
>>> If I remove the v3 bean, then both v4 methods are available.
>>>
>>> *Take the following from cxf_beans.xml where I define 2 service beans:*
>>>
>>>   <jaxrs:server id="serviceServer" address="/">
>>>     <jaxrs:serviceBeans>
>>>       <ref bean="contactServiceImpl3" />
>>>       <ref bean="contactServiceImpl4" />
>>>     </jaxrs:serviceBeans>
>>>
>>> *Here are the service interfaces:*
>>>
>>> =====
>>>
>>> @Path("/v3")
>>> public interface AuthenticationService {
>>>     @GET
>>>     @Path("/authenticate/{uid}:{pass}")
>>>     public Response authenticate(@PathParam("uid") String username,
>>> @PathParam("pass") String password);
>>> }
>>>
>>> =====
>>>
>>> @Path("/v4")
>>> public interface AuthenticationService {
>>>     @GET
>>>     @Path("/authenticate/{uid}:{pass}")
>>>     public Response authenticate(@PathParam("uid") String username,
>>> @PathParam("pass") String password);
>>>
>>>     @GET
>>>     @Path("/authenticate/validate/{token}")
>>>     public Response validate(@PathParam("token") String token);
>>> }
>>>
>>> =====

I'm presuming those 2 AuthenticationService(s) are in different packages ?

So if you do "/v4/authenticate/validate/BTaaZUycRa" then no operation can be found unless you remove a bean which implements
AuthenticationService with /v3 ?


cheers, Sergey

----- Original Message -----
From: "David Castro" <apudcastro@entwash.org>
To: <users@cxf.apache.org>
Sent: Thursday, April 16, 2009 1:59 AM
Subject: Re: JAXRS: Multiple service beans problem


> Have my own little conversation going here now ;)   So looking deeper at
> that other post, apparently you need to have a unique root path name for
> each service class for the matching to work right now.  Kind of a bummer
> that you can't have multiple classes with / for a root path and just have
> CXF search all / path classes for particular sub-resource locators. But at
> least I know how to get around the issue there.
>

Re: JAXRS: Multiple service beans problem

by Sergey Beryozkin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

See

http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ResourceComparator.java

it can be registered as jaxrs:server/jaxrs:resourceComparator

The custom implementation will be given a chance to select between multiple matching class resources or resource methods

thanks, Sergey


Done: https://issues.apache.org/jira/browse/CXF-2439


Hi Kynan

No, not yet. Please open the JIRA for it (make it 'Fix for 2.3')

thanks, Sergey

Kynan Fraser wrote:
Hi Sergey,

Was there a JIRA issue opened for this or has it been added as a feature?

Regards,
Kynan

Sergey Beryozkin-2 wrote:
Hi

It's just a JAXRS selection algorithm that dictates it, or rather, it does not allow for selecting between multiple resource classes
which have the same Path value. Perhaps you may want to consider using Path values with custom regular expressions rather than
hardcoding unique values into each root class's Path values.
I kind of like the idea of trying another resource class if the initially taken route through the initially chosen root class
produces no valid operation - I'll add it to the list...

Can you explain a bit more please about this issue :

>>> Not sure if it is related, but also ran into a similar problem, where when
>>> I have two service interfaces like below...where service A and B both have a
>>> common sub-path.  It seems that both /v3/authenticate and /v4/authenticate
>>> are available.  However, /v4/authenticate/validate is not available.  No
>>> sub-path for a method is available in v4 if v3 doesn't have the same path.
>>> If I remove the v3 bean, then both v4 methods are available.
>>>
>>> *Take the following from cxf_beans.xml where I define 2 service beans:*
>>>
>>>   <jaxrs:server id="serviceServer" address="/">
>>>     <jaxrs:serviceBeans>
>>>       <ref bean="contactServiceImpl3" />
>>>       <ref bean="contactServiceImpl4" />
>>>     </jaxrs:serviceBeans>
>>>
>>> *Here are the service interfaces:*
>>>
>>> =====
>>>
>>> @Path("/v3")
>>> public interface AuthenticationService {
>>>     @GET
>>>     @Path("/authenticate/{uid}:{pass}")
>>>     public Response authenticate(@PathParam("uid") String username,
>>> @PathParam("pass") String password);
>>> }
>>>
>>> =====
>>>
>>> @Path("/v4")
>>> public interface AuthenticationService {
>>>     @GET
>>>     @Path("/authenticate/{uid}:{pass}")
>>>     public Response authenticate(@PathParam("uid") String username,
>>> @PathParam("pass") String password);
>>>
>>>     @GET
>>>     @Path("/authenticate/validate/{token}")
>>>     public Response validate(@PathParam("token") String token);
>>> }
>>>
>>> =====

I'm presuming those 2 AuthenticationService(s) are in different packages ?

So if you do "/v4/authenticate/validate/BTaaZUycRa" then no operation can be found unless you remove a bean which implements
AuthenticationService with /v3 ?


cheers, Sergey

----- Original Message -----
From: "David Castro" <apudcastro@entwash.org>
To: <users@cxf.apache.org>
Sent: Thursday, April 16, 2009 1:59 AM
Subject: Re: JAXRS: Multiple service beans problem


> Have my own little conversation going here now ;)   So looking deeper at
> that other post, apparently you need to have a unique root path name for
> each service class for the matching to work right now.  Kind of a bummer
> that you can't have multiple classes with / for a root path and just have
> CXF search all / path classes for particular sub-resource locators. But at
> least I know how to get around the issue there.
>


Re: JAXRS: Multiple service beans problem

by Rick Gordon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have run into the same issue, coupled with the fact that this is my 2nd day of trying to use cxf.
can you provide any sort of example as to how this would be used?
(I ran into the same problem - wanting to provide multiple service implementations within a single url pattern. Something like "/service/test1" and "/service/test2".
Whichever one is listed first in the jaxrs:server is the one that matches. Creating multiple jaxrs:server elements didn't help (at least the way i did it.)


Hi,

See

http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ResourceComparator.java

it can be registered as jaxrs:server/jaxrs:resourceComparator

The custom implementation will be given a chance to select between multiple matching class resources or resource methods

thanks, Sergey


Done: https://issues.apache.org/jira/browse/CXF-2439

Sergey Beryozkin wrote:
Hi Kynan

No, not yet. Please open the JIRA for it (make it 'Fix for 2.3')

thanks, Sergey

Kynan Fraser wrote:
Hi Sergey,

Was there a JIRA issue opened for this or has it been added as a feature?

Regards,
Kynan

Sergey Beryozkin-2 wrote:
Hi

It's just a JAXRS selection algorithm that dictates it, or rather, it does not allow for selecting between multiple resource classes
which have the same Path value. Perhaps you may want to consider using Path values with custom regular expressions rather than
hardcoding unique values into each root class's Path values.
I kind of like the idea of trying another resource class if the initially taken route through the initially chosen root class
produces no valid operation - I'll add it to the list...

Can you explain a bit more please about this issue :

>>> Not sure if it is related, but also ran into a similar problem, where when
>>> I have two service interfaces like below...where service A and B both have a
>>> common sub-path.  It seems that both /v3/authenticate and /v4/authenticate
>>> are available.  However, /v4/authenticate/validate is not available.  No
>>> sub-path for a method is available in v4 if v3 doesn't have the same path.
>>> If I remove the v3 bean, then both v4 methods are available.
>>>
>>> *Take the following from cxf_beans.xml where I define 2 service beans:*
>>>
>>>   <jaxrs:server id="serviceServer" address="/">
>>>     <jaxrs:serviceBeans>
>>>       <ref bean="contactServiceImpl3" />
>>>       <ref bean="contactServiceImpl4" />
>>>     </jaxrs:serviceBeans>
>>>
>>> *Here are the service interfaces:*
>>>
>>> =====
>>>
>>> @Path("/v3")
>>> public interface AuthenticationService {
>>>     @GET
>>>     @Path("/authenticate/{uid}:{pass}")
>>>     public Response authenticate(@PathParam("uid") String username,
>>> @PathParam("pass") String password);
>>> }
>>>
>>> =====
>>>
>>> @Path("/v4")
>>> public interface AuthenticationService {
>>>     @GET
>>>     @Path("/authenticate/{uid}:{pass}")
>>>     public Response authenticate(@PathParam("uid") String username,
>>> @PathParam("pass") String password);
>>>
>>>     @GET
>>>     @Path("/authenticate/validate/{token}")
>>>     public Response validate(@PathParam("token") String token);
>>> }
>>>
>>> =====

I'm presuming those 2 AuthenticationService(s) are in different packages ?

So if you do "/v4/authenticate/validate/BTaaZUycRa" then no operation can be found unless you remove a bean which implements
AuthenticationService with /v3 ?


cheers, Sergey

----- Original Message -----
From: "David Castro" <apudcastro@entwash.org>
To: <users@cxf.apache.org>
Sent: Thursday, April 16, 2009 1:59 AM
Subject: Re: JAXRS: Multiple service beans problem


> Have my own little conversation going here now ;)   So looking deeper at
> that other post, apparently you need to have a unique root path name for
> each service class for the matching to work right now.  Kind of a bummer
> that you can't have multiple classes with / for a root path and just have
> CXF search all / path classes for particular sub-resource locators. But at
> least I know how to get around the issue there.
>

Re: JAXRS: Multiple service beans problem

by Sergey Beryozkin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

>
> I have run into the same issue, coupled with the fact that this is my 2nd day
> of trying to use cxf.
> can you provide any sort of example as to how this would be used?
> (I ran into the same problem - wanting to provide multiple service
> implementations within a single url pattern. Something like "/service/test1"
> and "/service/test2".

I've added some dcoumentation here :
http://cxf.apache.org/docs/jax-rs.html#JAX-RS-Customselectionbetweenmultipleresources

Note it is only supported in 2.2.5. Please register a custom resourceComparator impl.
From the ClassResourceInfo you can get the name of the actual class using a getServiceClass() method. Given the service class names
and the current request URI you can choose if you'd like to impose some custom ordering or not, 0 - if not.
I haven't had time to do a better documentation on this feature yet - but it should be quite straightforward to start using it. Ot
does requirte some knowledge of the internal api, but to the minimum (ClassResourceInfo.getServiceClass plus new
UriInfoImpl(message).getPath() and that is probably it).

cheers, Sergey



> Whichever one is listed first in the jaxrs:server is the one that matches.
> Creating multiple jaxrs:server elements didn't help (at least the way i did
> it.)
>
>
> Sergey Beryozkin wrote:
>>
>> Hi,
>>
>> See
>>
>> http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ResourceComparator.java
>>
>> it can be registered as jaxrs:server/jaxrs:resourceComparator
>>
>> The custom implementation will be given a chance to select between
>> multiple matching class resources or resource methods
>>
>> thanks, Sergey
>>