title: Jetty server cannot return json
body: <p>When I use mvn jetty:run to start my server, it cannot return json format string, it seems to only return raw string or "null" for all objects</p>
  
  <p>My endpoint code, you see there is no difference but to return string in a wrapped object and return as raw string</p>
  
  <p></p>
  
  <pre><code> @Path("/snapsono/")  
   public class RestEndPoint {  
       GeneralServer server = new GeneralImpl();  
       private Logger logger = Logger.getLogger("RestEndPoint");  
       @GET
       @Path("/hello")
       @Produces({MediaType.APPLICATION_JSON})
       public SnapString sayHello() throws Exception{
          logger.info("reach hello");
          SnapString snapString = new SnapString("hello");
          logger.info("this is: "+snapString.getString());
          return snapString;
       } 
  
       @GET
       @Path("/helloString")
       @Produces({MediaType.APPLICATION_JSON})
       public String sayHelloString() throws Exception{
          return "hello";
       }
     }
  </code></pre>
  
  <p></p>
  
  <p>For the SnapString class, I do add the @XmlRootElement at the class region
  </p>
  
  <pre><code>@XmlRootElement
  public class SnapString {
      private String str = "";
      public SnapString(){
      }
  
      public SnapString(String str){
          this.str = str;
      }
  
      public String getString(){
          return this.str;
      } 
  }
  </code></pre>
  
  <p></p>
  
  <p>but when I run it, I got the following return</p>
  
  <pre><code>dilin-mbp:~ dilin$ curl -i -H "Accept: application/json" -H "Content-Type:  application/json" -X GET http://localhost:9090/snapsono/hello
  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(8.1.16.v20140903)
  
  null
  
  dilin-mbp:~ dilcurl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://localhost:9090/snapsono/helloString
  HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(8.1.16.v20140903)
  
  hello
  
  dilin-mbp:~ dilin$
  </code></pre>
  
  <p>That is, it is ok to return a raw string but cannot return an object in Json format, and when it is wrapped, it is always return null.</p>
  
  <p>Mean while, from the log I can tell that the return object does have value</p>
  
  <pre><code>[INFO] Restart completed at Mon Feb 16 21:53:56 PST 2015
  Feb 16, 2015 9:54:48 PM snap.sono.demo.rest.RestEndPoint sayHello
  INFO: reach hello
  Feb 16, 2015 9:54:48 PM snap.sono.demo.rest.RestEndPoint sayHello
  INFO: this is: hello
  Feb 16, 2015 9:57:45 PM snap.sono.demo.rest.RestEndPoint sayHello
  </code></pre>
  
  <p>Please check my naive implementation for the two Info log</p>
  
  <p>The entire jetty start up message is:</p>
  
  <pre><code>dilin-mbp:snapsono dilin$ mvn jetty:run
  [INFO] Scanning for projects...
  [WARNING] Failed to retrieve plugin descriptor for org.eclipse.jetty:jetty-  server:8.1.8.v20121106: Failed to parse plugin descriptor for   org.eclipse.jetty:jetty-server:8.1.8.v20121106      (/Users/dilin/.m2/repository/org/eclipse/jetty/jetty-server/8.1.8.v20121106/jetty-  server-8.1.8.v20121106.jar): No plugin descriptor found at META-     INF/maven/plugin.xml
  [INFO]
  [INFO] ------------------------------------------------------------------------
  [INFO] Building Sproject 0.0.1-SNAPSHOT
  [INFO] ------------------------------------------------------------------------
  [WARNING] Failed to retrieve plugin descriptor for org.eclipse.jetty:jetty-server:8.1.8.v20121106: Failed to parse plugin descriptor for org.eclipse.jetty:jetty-server:8.1.8.v20121106   (/Users/dilin/.m2/repository/org/eclipse/jetty/jetty-server/8.1.8.v20121106/jetty-  server-8.1.8.v20121106.jar): No plugin descriptor found at META-  INF/maven/plugin.xml
  [INFO]
  [INFO] &gt;&gt;&gt; jetty-maven-plugin:8.1.8.v20121106:run (default-cli) &gt; test-compile @ Sproject &gt;&gt;&gt;
  [INFO]
  [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Sproject ---
  [WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
  [INFO] skip non existing resourceDirectory /Users/dilin/Documents/workspace/snapsono/src/main/resources
  [INFO]
  [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ Sproject ---
  [INFO] Nothing to compile - all classes are up to date
  [INFO]
  [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Sproject ---
  [WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
  [INFO] skip non existing resourceDirectory /Users/dilin/Documents/workspace/snapsono/src/test/resources
  [INFO]
  [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ Sproject ---
  [INFO] Nothing to compile - all classes are up to date
  [INFO]
  [INFO] &lt;&lt;&lt; jetty-maven-plugin:8.1.8.v20121106:run (default-cli) &lt; test-compile @ Sproject &lt;&lt;&lt;
  [INFO]
  [INFO] --- jetty-maven-plugin:8.1.8.v20121106:run (default-cli) @ Sproject ---
  [INFO] Configuring Jetty for project: Sproject
  [INFO] webAppSourceDirectory not set. Defaulting to /Users/dilin/Documents/workspace/snapsono/src/main/webapp
  [INFO] Reload Mechanic: automatic
  [INFO] Classes = /Users/dilin/Documents/workspace/snapsono/target/classes
  [INFO] Context path = /
  [INFO] Tmp directory = /Users/dilin/Documents/workspace/snapsono/target/tmp
  [INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
  [INFO] Web overrides =  none
  [INFO] web.xml file =     file:/Users/dilin/Documents/workspace/snapsono/src/main/webapp/WEB-INF/web.xml
  [INFO] Webapp directory = /Users/dilin/Documents/workspace/snapsono/src/main/webapp
  2015-02-16 22:00:01.766:INFO:oejs.Server:jetty-8.1.8.v20121106
  2015-02-16 22:00:02.128:INFO:oejpw.PlusConfiguration:No Transaction manager found - if your webapp requires one, please configure one.
  Null identity service, trying login service: null
  Finding identity service: null
  2015-02-16 22:00:03.549:INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebAppContext{/,file:/Users/dilin/Documents/workspace/snapsono/src/main/webapp/},file:/Users/dilin/Documents/workspace/snapsono/src/main/webapp/
  2015-02-16 22:00:03.549:INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebAppContext{/,file:/Users/dilin/Documents/workspace/snapsono/src/main/webapp/},file:/Users/dilin/Documents/workspace/snapsono/src/main/webapp/
  2015-02-16 22:00:03.549:INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebAppContext{/,file:/Users/dilin/Documents/workspace/snapsono/src/main/webapp/},file:/Users/dilin/Documents/workspace/snapsono/src/main/webapp/
  Feb 16, 2015 10:00:03 PM com.sun.jersey.api.core.PackagesResourceConfig init
  INFO: Scanning for root resource and provider classes in the packages:
    snap.sono.demo.rest
  Feb 16, 2015 10:00:03 PM com.sun.jersey.api.core.ScanningResourceConfig logClasses
  INFO: Root resource classes found:
    class snap.sono.demo.rest.RestEndPoint
  Feb 16, 2015 10:00:03 PM com.sun.jersey.api.core.ScanningResourceConfig init
  INFO: No provider classes found.
    Feb 16, 2015 10:00:03 PM     com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
  INFO: Initiating Jersey application, version 'Jersey: 1.8 06/24/2011 12:17 PM'
  2015-02-16 22:00:04.040:INFO:oejs.AbstractConnector:Started       SelectChannelConnector@0.0.0.0:9090
  [INFO] Started Jetty Server
  [INFO] Starting scanner at interval of 40 seconds.
  </code></pre>