title: Returning JSON Objects from jeJSrsey Rest Service
body: <p>I have a rest service which returns JSONObjects and JSONArrays</p>
  
  <p>I m trying to return </p>
  
  <p>import org.codehaus.jettison.json.JSONArray;
  import org.codehaus.jettison.json.JSONObject;</p>
  
  <p>from my Rest service. </p>
  
  <p>ex : </p>
  
  <pre><code> @Path("/SubgraphIds")
      @GET
      @Produces(MediaType.APPLICATION_JSON)
      public JSONArray getSubgraphIds() {
  
         .......
  
      }
  
      @Path("/Subgraph/id={id}/startTime={startTime}/duration={duration}")
      @GET
      @Produces(MediaType.APPLICATION_JSON)
      public JSONObject getSubgraph(@PathParam("id")String id ,@PathParam("startTime")String startTime ,
                                @PathParam("duration")String duration) {
  
      }
  </code></pre>
  
  <p>In my application i internally start my Own Rest service within the application by using com.sun.jersey.api.container.httpserver</p>
  
  <p>/**
               * Starting Service
               */
              this.resourceConfig = new PackagesResourceConfig(restPkg);</p>
  
  <pre><code>        resourceConfig.getFeatures().put(ClientConfig.FEATURE_DISABLE_XML_SECURITY, true);
          resourceConfig.getProperties().put(ClientConfig.FEATURE_DISABLE_XML_SECURITY, "true");
          resourceConfig.getClasses().add(JSONArrayProvider.class);
          resourceConfig.getClasses().add(JSONArrayProvider.class);
          this.httpServer = HttpServerFactory.create(getURL(port), resourceConfig);
  </code></pre>
  
  <p>But I get Following Error when starting the server. Any thoughts on resolving this is highly appreciated. (I m using jersey-core,jersey-server,jersey-json 1.1.1-ea verions).</p>
  
  <p>SEVERE: The provider class, class com.sun.jersey.json.impl.provider.entity.JSONArrayProvider, could not be instantiated. Processing will continue but the class will not be utilized
  java.lang.IllegalAccessException: Class com.sun.jersey.core.spi.component.ComponentConstructor can not access a member of class com.sun.jersey.json.impl.provider.entity.JSONArrayProvider with modifiers ""
      at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:95)
      at java.lang.Class.newInstance0(Class.java:368)
      at java.lang.Class.newInstance(Class.java:327)
      at com.sun.jersey.core.spi.component.ComponentConstructor.<em>getInstance(ComponentConstructor.java:152)
      at com.sun.jersey.core.spi.component.ComponentConstructor.getInstance(ComponentConstructor.java:140)
      at com.sun.jersey.core.spi.component.ProviderFactory.</em>_getComponentProvider(ProviderFactory.java:159)
      at com.sun.jersey.core.spi.component.ProviderFactory._getComponentProvider(ProviderFactory.java:152)
      at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:146)
      at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:124)
      at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:190)
      at com.sun.jersey.core.spi.component.ProviderServices.getProvidersAndServices(ProviderServices.java:120)
      at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:153)
      at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:145)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:609)
      at com.sun.jersey.api.container.ContainerFactory.createContainer(ContainerFactory.java:168)
      at com.sun.jersey.api.container.ContainerFactory.createContainer(ContainerFactory.java:130)
      at com.sun.jersey.api.container.httpserver.HttpServerFactory.create(HttpServerFactory.java:169)</p>