users@jersey.java.net

[Jersey] jersey json transformation(when running on osgi)

From: ?????? ??????? <atanas.i.todorov_at_gmail.com>
Date: Thu, 20 Oct 2011 15:27:23 +0300

Hi All,

I am running on OSGI and want to try out Jersey to build a Restful service.

*I have a simple POJO annotated with JAXB annotations*
@XmlRootElement
public class MyBean {

    private String name;
    private String description;
    public MyBean() {
        // TODO Auto-generated constructor stub
    }
    public MyBean(String name, String description) {
        super();
        this.name = name;
        this.description = description;
    }
    public String getName() {
        return name;
    }
    public String getDescription() {
        return description;
    }

}

*and a simple resource*

@Singleton
@Path("/test")
public class TestResource {

   @GET
   @Produces("application/json")
   public MyBean getTest(){
       return new MyBean("dfas", "dfa");
   }

}

*Questions: *
1. getTest() is invoked but have the following
Exception:java.lang.LinkageError: loader constraint violation: loader
(instance of <bootloader>) previously initiated loading for a different type
with name "javax/xml/stream/XMLStreamWriter"

I am using jdk 6 where javax/xml/stream/XMLStreamWriter is part of and jdk
jars are loaded first by default in OSGI.It seems Jersey uses some other
impl of XmlStreamWriter.Right?
Jersey dependencies i use:

   - jersey-core.jar
   - jersey-server.jar
   - jersey-json.jar

i tried to use jersey-bundle.jar but it has pretty much other dependencies
which are not resolved.


*note:text/xml mime type works as excpected but i want to try out json out
of the box transformation*

*
*