title: Jersey 2 initialization: The resource configuration is not modifiable in this context
body: <p>I'm using IntelliJ 2016 Ultimate as IDE for developing a JAX-RS 2.0 webapplication.</p>
  
  <p>The webapp works fine when deployed as WAR artifact on various remote WebLogic machines.</p>
  
  <p>However, when deployed as an exploded artifact (on a local WebLogic installation (read: the target/webbap directory) Jersey <em>sometimes</em> fails to initialize correctly, with the following exception:
  <strong>The resource configuration is not modifiable in this context.</strong></p>
  
  <pre class="lang-java prettyprint-override">
  java.lang.IllegalStateException: The resource configuration is not modifiable in this context.
      at org.glassfish.jersey.server.ResourceConfig$ImmutableState.register(ResourceConfig.java:274)
      at org.glassfish.jersey.server.ResourceConfig$ImmutableState.register(ResourceConfig.java:221)
      at org.glassfish.jersey.server.ResourceConfig.register(ResourceConfig.java:453)
      at org.glassfish.jersey.servlet.WebComponent.(WebComponent.java:385)
      at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
      at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:362)
      at javax.servlet.GenericServlet.init(GenericServlet.java:244)
      at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:343)
      at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:294)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326)
      at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:196)
      at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
      at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
      at weblogic.servlet.internal.StubSecurityHelper.initServletInstance(StubSecurityHelper.java:99)
      at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:93)
      at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:69)
      at weblogic.servlet.internal.StubLifecycleHelper.(StubLifecycleHelper.java:57)
      at weblogic.servlet.internal.StubLifecycleHelper.(StubLifecycleHelper.java:36)
      at weblogic.servlet.internal.ServletStubImpl.initStubLifecycleHelper(ServletStubImpl.java:666)
      at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:612)
      at weblogic.servlet.internal.ServletStubImpl.reloadWhenClassloaderChanged(ServletStubImpl.java:562)
      at weblogic.servlet.internal.ServletStubImpl.checkForReload(ServletStubImpl.java:530)
      at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:411)
      at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:304)
      at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
      ....
  </pre>
  
  <p>This happens on the very first request to a resource. It doesn't matter which resource, I've seen it happen on many different resources.
  The only solution at this point is a restart of the webapp.</p>
  
  <p><strong>Tech stack</strong></p>
  
  <ul>
  <li>WebLogic 12.2.1</li>
  <li>Maven 3.2.3</li>
  <li>Java 8</li>
  <li>JavaEE 7</li>
  <li>JAX-RS 2.0 / Jersey 2.21 (bundled with WebLogic)</li>
  </ul>
  
  <p><strong>IDE</strong></p>
  
  <ul>
  <li>IntelliJ 2016.1 Ultimate</li>
  </ul>
  
  <p>It is pretty hard to reproduce reliably, sometimes the Jersey initializion fails 5 times in a row, at other times 10 times without problems.</p>
  
  <p>I'm not sure what precisely goes wrong. Can anyone give me some explanation of what exactly fails during initialization, or an idea how to debug this problem.</p>