Hi Ricardo,
The issue is the JAXB RI is instantiating an instance of Sample since
it is not aware of Spring.
You might want to check out the JAXB support provided by Spring i.e.
try and replace the default JAXB RI support with the JAXB Spring
support.
Paul.
On Jan 25, 2011, at 12:02 PM, Ricardo Borillo wrote:
> Hi all,
>
> I'm using SpringServlet with Jersey 1.4.
> For the system design, i have DAO objects to access data and model
> objects to implement my business logic:
>
> @Component
> @XmlRootElement
> public cass Sample {
> @Autowired
> public MyDAO myDAO;
> ... methods and attributes ...
>
> public void update()
> {
> myDAO.update(this);
> }
> }
>
> My service layer access the model and the model access data through
> DAO implementation.
>
> In the service layer, i have my jersey methods:
>
> @PUT
> @Path("{id}")
> @Produces(MediaType.TEXT_XML)
> @Consumes(MediaType.TEXT_XML)
> public Response update(Sample sample)
> {
> sample.update();
> return Response.ok(sample).build();
> }
>
> The problem is that the bean "sample" received by the previous
> method, is not a Spring Bean and the collaborators are not
> autowired ...
> Is it possible to get from Jersey a class "Sample" instance
> autowired by Spring?
>
> I try to add InjectParam in the method, but i only get a new
> instance without the HTTP data from client:
>
> @PUT
> @Path("{id}")
> @Produces(MediaType.TEXT_XML)
> @Consumes(MediaType.TEXT_XML)
> public Response update(@InjectParam Sample sample)
>
> Thanks in advance
>
> ---
> Salut,
> ====================================
> Ricardo Borillo Domenech
> http://xml-utils.com
> twitter: @borillo