You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by tttsh <Ta...@objectconsulting.com.au> on 2008/06/12 04:47:06 UTC

jax-rs strange behaviour resolving end-points

I found a strange behaviour with the way cxf resolves operations.
 
If the exchange the position of the method getCatalog and getCatalogList(of
the code below) I end up with:
 
2/06/2008 12:07:56 org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor
handleMessage
INFO: Found operation: getCatalog
12/06/2008 12:07:56 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now
java.lang.NullPointerException
 at org.apache.cxf.jaxrs.JAXRSUtils.readFromUriParam(JAXRSUtils.java:513)
 
 
but if i have the code as below it resolves correctly as intended. 
 
Am I doing something wrong? Is this going to resolved like so always or
randomly?
 
 
@Path("/{franchise}/{location}/{language}/catalog")
public class CatalogRestService {
 
    public CatalogRestService() {
    }

    @GET
    @Path("{catalog}")
    public Catalog getCatalog(@PathParam("franchise") String franchise,
                                    @PathParam("location") String location,
                                    @PathParam("language") String language,
                                    @PathParam("catalog") String catalog,
                                    @QueryParam("builddate") String
builddate) throws DataException {

...
    }
 
    @GET
    public Reference getCatalogList(@PathParam("franchise") String
franchise,
                                    @PathParam("location") String location,
                                    @PathParam("language") String language,
                                    @QueryParam("searchtype") String
searchType,
                                    @QueryParam("searchstring") String
searchString) throws DataException {
...
   }
 
-- 
View this message in context: http://www.nabble.com/jax-rs-strange-behaviour-resolving-end-points-tp17791427p17791427.html
Sent from the cxf-user mailing list archive at Nabble.com.


RE: jax-rs strange behaviour resolving end-points

Posted by tttsh <Ta...@objectconsulting.com.au>.

It's now resolved, it was a matter of getting the order right. 
Cheers, thanks for the help.


Sergey Beryozkin wrote:
> 
> Can you post a sample of how you're extending it please ?
> 
> Cheers, Sergey
> 
> -----Original Message-----
> From: tttsh [mailto:Tao.Shen@objectconsulting.com.au] 
> Sent: 12 June 2008 08:11
> To: users@cxf.apache.org
> Subject: Re: jax-rs strange behaviour resolving end-points
> 
> 
> 
> Also extending on the sample project jax-rs/basic it can not support the
> same resource using sub-resource such that:
> 
> to return a list in customerservice with @GET:
> http://domain/customerservice/order/
> 
> to return a order instance in customerservice with @GET("{orderid}")
> http://domain/customerservice/order/456
> 
> to return a sub-resource with no @GET
> http://domain/customerservice/order/456/product/5
> 
> 
> 
> tttsh wrote:
>> 
>> I found a strange behaviour with the way cxf resolves operations.
>>  
>> If the exchange the position of the method getCatalog and
>> getCatalogList(of the code below) I end up with:
>>  
>> 2/06/2008 12:07:56 org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor
>> handleMessage
>> INFO: Found operation: getCatalog
>> 12/06/2008 12:07:56 org.apache.cxf.phase.PhaseInterceptorChain
>> doIntercept
>> INFO: Interceptor has thrown exception, unwinding now
>> java.lang.NullPointerException
>>  at org.apache.cxf.jaxrs.JAXRSUtils.readFromUriParam(JAXRSUtils.java:513)
>>  
>>  
>> but if i have the code as below it resolves correctly as intended. 
>>  
>> Am I doing something wrong? Is this going to resolved like so always or
>> randomly?
>>  
>>  
>> @Path("/{franchise}/{location}/{language}/catalog")
>> public class CatalogRestService {
>>  
>>     public CatalogRestService() {
>>     }
>> 
>>     @GET
>>     @Path("{catalog}")
>>     public Catalog getCatalog(@PathParam("franchise") String franchise,
>>                                     @PathParam("location") String
>> location,
>>                                     @PathParam("language") String
>> language,
>>                                     @PathParam("catalog") String catalog,
>>                                     @QueryParam("builddate") String
>> builddate) throws DataException {
>> 
>> ...
>>     }
>>  
>>     @GET
>>     public Reference getCatalogList(@PathParam("franchise") String
>> franchise,
>>                                     @PathParam("location") String
>> location,
>>                                     @PathParam("language") String
>> language,
>>                                     @QueryParam("searchtype") String
>> searchType,
>>                                     @QueryParam("searchstring") String
>> searchString) throws DataException {
>> ...
>>    }
>>  
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/jax-rs-strange-behaviour-resolving-end-points-tp177914
> 27p17793875.html
> Sent from the cxf-user mailing list archive at Nabble.com.
> 
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
> 
> 

-- 
View this message in context: http://www.nabble.com/jax-rs-strange-behaviour-resolving-end-points-tp17791427p17812338.html
Sent from the cxf-user mailing list archive at Nabble.com.


RE: jax-rs strange behaviour resolving end-points

Posted by Sergey Beryozkin <se...@iona.com>.
Can you post a sample of how you're extending it please ?

Cheers, Sergey

-----Original Message-----
From: tttsh [mailto:Tao.Shen@objectconsulting.com.au] 
Sent: 12 June 2008 08:11
To: users@cxf.apache.org
Subject: Re: jax-rs strange behaviour resolving end-points



Also extending on the sample project jax-rs/basic it can not support the
same resource using sub-resource such that:

to return a list in customerservice with @GET:
http://domain/customerservice/order/

to return a order instance in customerservice with @GET("{orderid}")
http://domain/customerservice/order/456

to return a sub-resource with no @GET
http://domain/customerservice/order/456/product/5



tttsh wrote:
> 
> I found a strange behaviour with the way cxf resolves operations.
>  
> If the exchange the position of the method getCatalog and
> getCatalogList(of the code below) I end up with:
>  
> 2/06/2008 12:07:56 org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor
> handleMessage
> INFO: Found operation: getCatalog
> 12/06/2008 12:07:56 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
> INFO: Interceptor has thrown exception, unwinding now
> java.lang.NullPointerException
>  at org.apache.cxf.jaxrs.JAXRSUtils.readFromUriParam(JAXRSUtils.java:513)
>  
>  
> but if i have the code as below it resolves correctly as intended. 
>  
> Am I doing something wrong? Is this going to resolved like so always or
> randomly?
>  
>  
> @Path("/{franchise}/{location}/{language}/catalog")
> public class CatalogRestService {
>  
>     public CatalogRestService() {
>     }
> 
>     @GET
>     @Path("{catalog}")
>     public Catalog getCatalog(@PathParam("franchise") String franchise,
>                                     @PathParam("location") String
> location,
>                                     @PathParam("language") String
> language,
>                                     @PathParam("catalog") String catalog,
>                                     @QueryParam("builddate") String
> builddate) throws DataException {
> 
> ...
>     }
>  
>     @GET
>     public Reference getCatalogList(@PathParam("franchise") String
> franchise,
>                                     @PathParam("location") String
> location,
>                                     @PathParam("language") String
> language,
>                                     @QueryParam("searchtype") String
> searchType,
>                                     @QueryParam("searchstring") String
> searchString) throws DataException {
> ...
>    }
>  
> 

-- 
View this message in context:
http://www.nabble.com/jax-rs-strange-behaviour-resolving-end-points-tp177914
27p17793875.html
Sent from the cxf-user mailing list archive at Nabble.com.

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Re: jax-rs strange behaviour resolving end-points

Posted by tttsh <Ta...@objectconsulting.com.au>.

Also extending on the sample project jax-rs/basic it can not support the
same resource using sub-resource such that:

to return a list in customerservice with @GET:
http://domain/customerservice/order/

to return a order instance in customerservice with @GET("{orderid}")
http://domain/customerservice/order/456

to return a sub-resource with no @GET
http://domain/customerservice/order/456/product/5



tttsh wrote:
> 
> I found a strange behaviour with the way cxf resolves operations.
>  
> If the exchange the position of the method getCatalog and
> getCatalogList(of the code below) I end up with:
>  
> 2/06/2008 12:07:56 org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor
> handleMessage
> INFO: Found operation: getCatalog
> 12/06/2008 12:07:56 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
> INFO: Interceptor has thrown exception, unwinding now
> java.lang.NullPointerException
>  at org.apache.cxf.jaxrs.JAXRSUtils.readFromUriParam(JAXRSUtils.java:513)
>  
>  
> but if i have the code as below it resolves correctly as intended. 
>  
> Am I doing something wrong? Is this going to resolved like so always or
> randomly?
>  
>  
> @Path("/{franchise}/{location}/{language}/catalog")
> public class CatalogRestService {
>  
>     public CatalogRestService() {
>     }
> 
>     @GET
>     @Path("{catalog}")
>     public Catalog getCatalog(@PathParam("franchise") String franchise,
>                                     @PathParam("location") String
> location,
>                                     @PathParam("language") String
> language,
>                                     @PathParam("catalog") String catalog,
>                                     @QueryParam("builddate") String
> builddate) throws DataException {
> 
> ...
>     }
>  
>     @GET
>     public Reference getCatalogList(@PathParam("franchise") String
> franchise,
>                                     @PathParam("location") String
> location,
>                                     @PathParam("language") String
> language,
>                                     @QueryParam("searchtype") String
> searchType,
>                                     @QueryParam("searchstring") String
> searchString) throws DataException {
> ...
>    }
>  
> 

-- 
View this message in context: http://www.nabble.com/jax-rs-strange-behaviour-resolving-end-points-tp17791427p17793875.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: jax-rs strange behaviour resolving end-points

Posted by Sergey Beryozkin <se...@iona.com>.
This is fixed in my local copy of the trunk and it will be merged during the next 2 weeks or so.
The good thing is that you've found a workaround :-)

Thanks, Sergey

> 
> 
> FYI 
> 
> I just tried it with  SNAPSHOT apache-cxf-2.1.1-20080605.204511-10 and it
> has the same problem.
> 
> The working (order) code can be found below, if the position of getOrderItem
> and getOrder is swapped getOrderItem is resolved to getOrder instead.
> 
> @Path("/customerservice/order/")
> public class CustomerService {
> 
>    Map<Long, Customer> customers = new HashMap<Long, Customer>();
>    Map<Long, Order> orders = new HashMap<Long, Order>();
> 
>    public CustomerService() {
>        init();
> 
>    }
> 
>    @GET
>    @Path("{orderId}")
>    public Order getOrderItem(@PathParam("orderId") String orderId) {
>        System.out.println("----invoking getOrderItem, Order id is: " +
> orderId);
>        long idNumber = Long.parseLong(orderId);
>        Order c = orders.get(idNumber);
>        return c;
>    }
> 
> 
>    @Path("{orderId}")
>    public Order getOrder(@PathParam("orderId") String orderId) {
>        System.out.println("----invoking getOrder, Order id is: " +
> orderId);
>        long idNumber = Long.parseLong(orderId);
>        Order c = orders.get(idNumber);
>        return c;
>    }
> 
>    @GET
>    public List<Order> getOrderList() {
>        System.out.println("----invoking getOrderList");
> 
>        return null;
>    }    
> 
>    final void init() {
> 
> 
> 
>        Customer c = new Customer();
>        c.setName("John");
>        c.setId(123);
>        customers.put(c.getId(), c);
> 
> 
>        Order o = new Order();
>        o.setName("order 223");
>        o.setId(223);
>        orders.put(o.getId(), o);
>    }
> 
> }
> 
> 
> 
> -- 
> View this message in context: http://www.nabble.com/jax-rs-strange-behaviour-resolving-end-points-tp17791427p17812563.html
> Sent from the cxf-user mailing list archive at Nabble.com.

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

RE: jax-rs strange behaviour resolving end-points

Posted by tttsh <Ta...@objectconsulting.com.au>.

FYI 

I just tried it with  SNAPSHOT apache-cxf-2.1.1-20080605.204511-10 and it
has the same problem.

The working (order) code can be found below, if the position of getOrderItem
and getOrder is swapped getOrderItem is resolved to getOrder instead.

@Path("/customerservice/order/")
public class CustomerService {

    Map<Long, Customer> customers = new HashMap<Long, Customer>();
    Map<Long, Order> orders = new HashMap<Long, Order>();

    public CustomerService() {
        init();

    }

    @GET
    @Path("{orderId}")
    public Order getOrderItem(@PathParam("orderId") String orderId) {
        System.out.println("----invoking getOrderItem, Order id is: " +
orderId);
        long idNumber = Long.parseLong(orderId);
        Order c = orders.get(idNumber);
        return c;
    }


    @Path("{orderId}")
    public Order getOrder(@PathParam("orderId") String orderId) {
        System.out.println("----invoking getOrder, Order id is: " +
orderId);
        long idNumber = Long.parseLong(orderId);
        Order c = orders.get(idNumber);
        return c;
    }

    @GET
    public List<Order> getOrderList() {
        System.out.println("----invoking getOrderList");

        return null;
    }    

    final void init() {



        Customer c = new Customer();
        c.setName("John");
        c.setId(123);
        customers.put(c.getId(), c);


        Order o = new Order();
        o.setName("order 223");
        o.setId(223);
        orders.put(o.getId(), o);
    }

}



-- 
View this message in context: http://www.nabble.com/jax-rs-strange-behaviour-resolving-end-points-tp17791427p17812563.html
Sent from the cxf-user mailing list archive at Nabble.com.


RE: jax-rs strange behaviour resolving end-points

Posted by Sergey Beryozkin <se...@iona.com>.
Hi

Brady's patch has been applied to fix this intermittent problem... 

Cheers, Sergey

-----Original Message-----
From: tttsh [mailto:Tao.Shen@objectconsulting.com.au] 
Sent: 12 June 2008 03:47
To: users@cxf.apache.org
Subject: jax-rs strange behaviour resolving end-points


I found a strange behaviour with the way cxf resolves operations.
 
If the exchange the position of the method getCatalog and getCatalogList(of
the code below) I end up with:
 
2/06/2008 12:07:56 org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor
handleMessage
INFO: Found operation: getCatalog
12/06/2008 12:07:56 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now
java.lang.NullPointerException
 at org.apache.cxf.jaxrs.JAXRSUtils.readFromUriParam(JAXRSUtils.java:513)
 
 
but if i have the code as below it resolves correctly as intended. 
 
Am I doing something wrong? Is this going to resolved like so always or
randomly?
 
 
@Path("/{franchise}/{location}/{language}/catalog")
public class CatalogRestService {
 
    public CatalogRestService() {
    }

    @GET
    @Path("{catalog}")
    public Catalog getCatalog(@PathParam("franchise") String franchise,
                                    @PathParam("location") String location,
                                    @PathParam("language") String language,
                                    @PathParam("catalog") String catalog,
                                    @QueryParam("builddate") String
builddate) throws DataException {

....
    }
 
    @GET
    public Reference getCatalogList(@PathParam("franchise") String
franchise,
                                    @PathParam("location") String location,
                                    @PathParam("language") String language,
                                    @QueryParam("searchtype") String
searchType,
                                    @QueryParam("searchstring") String
searchString) throws DataException {
....
   }
 
-- 
View this message in context:
http://www.nabble.com/jax-rs-strange-behaviour-resolving-end-points-tp177914
27p17791427.html
Sent from the cxf-user mailing list archive at Nabble.com.

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland