title: Null pointer exception whilst trying to use Jersey client
body: <p>I am trying to use the Jersey client to access a remote web service. Here is my code that makes the request:</p>
  
  <pre><code>Client client = Client.create();
  WebResource resource = client.resource(request.getUrl());
  
  Builder builder = resource.accept("application/json");
  String response = builder.post(String.class, request.getPayload());
  </code></pre>
  
  <p>I have bundled this into an OSGi bundle and installed it on Adobe CQ CMS.</p>
  
  <p>When trying to run the request code in the CMS I get the following stacktrace:</p>
  
  <pre><code>Caused by: java.lang.ExceptionInInitializerError
  at com.sun.jersey.core.spi.factory.MessageBodyFactory.getMessageBodyWriterMediaTypes(MessageBodyFactory.java:444)
  at com.sun.jersey.api.client.RequestWriter.getMediaType(RequestWriter.java:324)
  at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:282)
  at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:204)
  at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:147)
  at com.sun.jersey.api.client.Client.handle(Client.java:648)
  at com.sun.jersey.api.client.WebResource.handle(WebResource.java:680)
  at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
  at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:568)
  at com.myapp.auth.request.impl.HttpRequestSender.sendRequest(HttpRequestSender.java:44)
  at com.myapp.auth.ws.clients.impl.AuthenticateClientImpl.authenticate(AuthenticateClientImpl.java:47)
  at com.myapp.auth.Authenticator.authenticate(Authenticator.java:31)
  at org.apache.jsp.apps.angry_002dnerds.components.page.base.content_jsp._jspService(content_jsp.java:155)
  at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
  at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:420)
  ... 126 more
  </code></pre>
  
  <p>Caused by: java.lang.NullPointerException
      at javax.ws.rs.core.MediaType.valueOf(MediaType.java:119)
      at com.sun.jersey.core.header.MediaTypes.(MediaTypes.java:64)
      ... 142 more</p>
  
  <p>I have looked around and seen that others have had similar errors with MediaType throwing NullPointerExceptions on different platforms..</p>
  
  <p>Has anyone seen this issue before? </p>