title: Bundle wiring is no longer valid for Pax-Exam probe
body: <p>I developed a perfectly working test in Pax-Exam 4.8.0 and Karaf 4.0.3: I recently upgraded both Pax-Exam and Karaf and now I'm trying to debug a quite obscure error I get with <strong>Pax-Exam 4.9.1</strong> and <strong>Karaf 4.0.6</strong>.</p>
  <h3>You can find a self contained example of this problem <a href="https://github.com/mrulli/com.flairbit.osgi.paxexam-issue" rel="nofollow noreferrer">here</a>.</h3>
  <p>In my junit class I inject the following field:</p>
  <pre><code>@RunWith(PaxExam.class)
  @ExamReactorStrategy(PerClass.class)
  public class CustomerMockDBGeneratorTest extends TestCase {
  
      @Inject
      private static LogService log;
  
      @Inject
      private static BundleContext bcontext;
  
      ...
  
  
      @Test
      public void createMockDataBase() {
          // customerMockDBGeneratorTest.java:142 in the stacktrace below:
          ServiceReference&lt;CustomerUserStorageService&gt; ustoreservice = 
              bcontext.getServiceReference(CustomerUserStorageService.class); 
          ...
  </code></pre>
  <p>apparently the Pax-Exam probe is invalidated for some reasons and in my <code>@Test</code> method above I get the following error as soon as I use the bundle context to get a reference to the <code>CustomerUserStorageService</code> service:</p>
  <pre><code>java.lang.ClassNotFoundException: Unable to load class 'com.example.customer.storage.users.api.customerUserStorageService' because the bundle wiring for PAXEXAM-PROBE-a1ea3766-7d38-4fc2-b3eb-e33192ab8993 is no longer valid.
      at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1539)
      at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)
      at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at com.example.customer.storage.provider.customerMockDBGeneratorTest.createMockDataBase(customerMockDBGeneratorTest.java:142)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      at org.ops4j.pax.exam.invoker.junit.internal.ContainerTestRunner.runChild(ContainerTestRunner.java:68)
      at org.ops4j.pax.exam.invoker.junit.internal.ContainerTestRunner.runChild(ContainerTestRunner.java:37)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
      at org.ops4j.pax.exam.invoker.junit.internal.JUnitProbeInvoker.invokeViaJUnit(JUnitProbeInvoker.java:124)
      at org.ops4j.pax.exam.invoker.junit.internal.JUnitProbeInvoker.findAndInvoke(JUnitProbeInvoker.java:97)
      at org.ops4j.pax.exam.invoker.junit.internal.JUnitProbeInvoker.call(JUnitProbeInvoker.java:73)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.ops4j.pax.exam.rbc.internal.RemoteBundleContextImpl.remoteCall(RemoteBundleContextImpl.java:80)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
      at sun.rmi.transport.Transport$1.run(Transport.java:200)
      at sun.rmi.transport.Transport$1.run(Transport.java:197)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  <p>I honestly have no clue of why the probe bundle gets invalidated: why this could happen? Anyone experienced a similar situation?</p>
  <p><strong>The very same code is working fine with Pax-Exam v 4.8.0 and Karaf 4.0.3.</strong></p>