users@jersey.java.net

[Jersey] Annotations not working on single object but working fine on list<> of same objects (on Glassfish4)

From: Christ BE <christ4be_at_gmail.com>
Date: Tue, 17 Sep 2013 21:53:21 +0200

Here is the maven project for testing. 5 customers are create once when
calling http://localhost:8080/emberGF4/rest/customers

c:>curl -H "Accept:application/json"
http://localhost:8080/emberGF4/rest/customers
result should look like this:
{"customers":[{"id":1,"first_name":"F1","last_name":"L1","order_ids" :
[1]},{"id":2,"first_name":"F2","last_name":"L2","order_ids":[]}]}

now the problem no Jackson formating on single instance of same object

c:>curl -H "Accept:application/json"
http://localhost:8080/emberGF4/rest/customers/2
result is
{"firstName":"F2","id":2,"lastName":"L2","orders":[]}

but should be
{"customer":{"id":2,"firstName":"F2","lastName":"L2","order_ids":[]}}


I did a stack trace compare between at the return of list call and 1 object
and I notice there is a difference
>>> List<T> methode
CustomerService.get(List<Long>) line: 61
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 601
ContextBeanInstance<T>(AbstractBeanInstance).invoke(Object, Method,
Object...) line: 46
ProxyMethodHandler.invoke(Object, Method, Method, Object[]) line: 101
CustomerService$Proxy$_$$_WeldClientProxy.get(List) line: not available
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]


>>> single instance of object
CustomerService.get(Long) line: 69
CustomerService$Proxy$_$$_WeldClientProxy.get(Long) line: not available
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]

Any what the problem could be