title: Using Jersey Test Framework produces NullPointerException during JerseyTest constructor
body: <p>I am using Jersey Test Framework, however, even before the code gets to my test, the JerseyTest constructor fails with:</p>
  
  <pre><code>Mar 06, 2014 6:40:44 PM org.glassfish.jersey.server.ApplicationHandler initialize
  INFO: Initiating Jersey application, version Jersey: 2.6 2014-02-18 21:52:53...
  
  A MultiException has 3 exceptions.  They are:
  1. java.lang.NullPointerException
  2. java.lang.IllegalStateException: Unable to perform operation: method inject on com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$App
  3. java.lang.IllegalStateException: Unable to perform operation: create on org.glassfish.jersey.message.internal.MessageBodyFactory
  MultiException stack 1 of 3
  java.lang.NullPointerException
      at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.setConfiguration(AbstractJAXBProvider.java:112)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at org.glassfish.hk2.utilities.reflection.ReflectionHelper.invoke(ReflectionHelper.java:1017)
      at org.jvnet.hk2.internal.ClazzCreator.methodMe(ClazzCreator.java:375)
      at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:428)
      at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
      at org.jvnet.hk2.internal.PerLookupContext.findOrCreate(PerLookupContext.java:69)
      at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2445)
  </code></pre>
  
  <p>My test is very simple:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration({"/applicationContext-test.xml"})
  public class BidAPITest extends JerseyTest {
  
      @Override
      protected Application configure() {
          return new ResourceConfig(BidAPI.class);
      }
  
      @Test
      public void testCreate() {
          final BidDocument
              bid =
                  target(BidAPI.PATH)
                      .request()
                      .post(
                          Entity.entity("", MediaType.APPLICATION_JSON_TYPE),
                          BidDocument.class
                      );
  
          System.out.println(bid);
      }
  }
  </code></pre>
  
  <p>The actual failure occurs while setConfiguration is being invoked in AbstractJAXBProvider.  The actual line which fails in the JettyTest constructor is:</p>
  
  <pre><code>public ComponentModelValidator(ServiceLocator locator) {
      validators = Lists.newArrayList();
      validators.add(new ResourceValidator());
      /* -FAILS-&gt; */ validators.add(new RuntimeResourceModelValidator(locator.getService(MessageBodyWorkers.class)));
      validators.add(new ResourceMethodValidator(locator));
      validators.add(new InvocableValidator());
  }
  </code></pre>
  
  <p>Any ideas before I start ripping apart my application?</p>
  
  <p>Thanks.
  -AP_</p>