title: Problems testing services created with maven-scr-plugin when using pax-exam
body: <p>I've set up a very simple "HelloWorld" service to demonstrate my problem.  It uses the maven-scr-plugin to generate a service descriptor and has a pax-exam unit test.  But when I try to run 'mvn clean test' it blocks for a while before giving me this error:</p>
  
  <pre><code> org.ops4j.pax.swissbox.tracker.ServiceLookupException: gave up waiting for service com.liveops.examples.osgi.helloworld.HelloWorldService
  </code></pre>
  
  <p>If I run 'mvn -DskipTests=true package' and then run 'mvn test' (without clean)
  it works.  The difference seems to be the addition of this line in my META-INF/M
  ANIFEST.MF file:</p>
  
  <pre><code> Service-Component: OSGI-INF/com.liveops.examples.osgi.helloworld.internal.HelloImpl.xml
  </code></pre>
  
  <p>Does anyone know if there is a way to make sure this line is added earlier in the build process so that 'mvn clean test' will pass?  Or is there something else I might be doing wrong?</p>
  
  <hr>
  
  <p>For reference, here is the pom.xml, the service, and the unit test.</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.liveops.examples&lt;/groupId&gt;
      &lt;artifactId&gt;HelloWorldService&lt;/artifactId&gt;
      &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;
  
      &lt;packaging&gt;bundle&lt;/packaging&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.osgi&lt;/groupId&gt;
              &lt;artifactId&gt;org.osgi.core&lt;/artifactId&gt;
              &lt;version&gt;4.3.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.inject&lt;/groupId&gt;
              &lt;artifactId&gt;javax.inject&lt;/artifactId&gt;
              &lt;version&gt;1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.ops4j.pax.exam&lt;/groupId&gt;
              &lt;artifactId&gt;pax-exam&lt;/artifactId&gt;
              &lt;version&gt;3.3.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
               &lt;groupId&gt;org.ops4j.pax.exam&lt;/groupId&gt;
               &lt;artifactId&gt;pax-exam-container-native&lt;/artifactId&gt;
               &lt;version&gt;3.3.0&lt;/version&gt;
               &lt;scope&gt;test&lt;/scope&gt;
           &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.ops4j.pax.exam&lt;/groupId&gt;
              &lt;artifactId&gt;pax-exam-junit4&lt;/artifactId&gt;
              &lt;version&gt;3.3.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.ops4j.pax.url&lt;/groupId&gt;
              &lt;artifactId&gt;pax-url-aether&lt;/artifactId&gt;
              &lt;version&gt;1.6.0&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.ops4j.pax.exam&lt;/groupId&gt;
              &lt;artifactId&gt;pax-exam-link-mvn&lt;/artifactId&gt;
              &lt;version&gt;3.3.0&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-simple&lt;/artifactId&gt;
              &lt;version&gt;1.5.8&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
              &lt;artifactId&gt;org.apache.felix.framework&lt;/artifactId&gt;
              &lt;version&gt;4.0.2&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;     
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
              &lt;artifactId&gt;org.apache.felix.scr.annotations&lt;/artifactId&gt;
              &lt;version&gt;1.9.0&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;properties&gt;
          &lt;namespace&gt;com.liveops.examples.osgi.helloworld&lt;/namespace&gt;
      &lt;/properties&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.0&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.7&lt;/source&gt;
                      &lt;target&gt;1.7&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                  &lt;!--
                   | the following instructions build a simple set of public/private classes into an OSGi bundle
                  --&gt;
                  &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3.7&lt;/version&gt;
                  &lt;extensions&gt;true&lt;/extensions&gt;                
                  &lt;configuration&gt;
                      &lt;instructions&gt;
                          &lt;Bundle-SymbolicName&gt;${project.name}&lt;/Bundle-SymbolicName&gt;
                          &lt;Bundle-Version&gt;${project.version}&lt;/Bundle-Version&gt;
                          &lt;!-- Bundle-Activator&gt;${namespace}.internal.HelloActivator&lt;/Bundle-Activator --&gt;
                          &lt;!--
                           | assume public classes are in the top package, and private classes are under ".internal"
                          --&gt;
                          &lt;Export-Package&gt;!${namespace}.internal.*,${namespace}.*;version="${project.version}"&lt;/Export-Package&gt;
                          &lt;Private-Package&gt;${namespace}.internal.*&lt;/Private-Package&gt;
                          &lt;!--
                           | each module can override these defaults in their osgi.bnd file
       --&gt;
                          &lt;!--_include&gt;-osgi.bnd&lt;/_include--&gt;
                      &lt;/instructions&gt;
                  &lt;/configuration&gt;   
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;generate-manifest&lt;/id&gt;
                          &lt;phase&gt;process-classes&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;manifest&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;          
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-scr-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.9.0&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;supportedProjectTypes&gt;
                          &lt;supportedProjectType&gt;jar&lt;/supportedProjectType&gt;
                          &lt;supportedProjectType&gt;bundle&lt;/supportedProjectType&gt;
                          &lt;supportedProjectType&gt;war&lt;/supportedProjectType&gt;
                      &lt;/supportedProjectTypes&gt;
                      &lt;generateAccessors&gt;true&lt;/generateAccessors&gt;
                      &lt;strictMode&gt;true&lt;/strictMode&gt;
                      &lt;specVersion&gt;1.1&lt;/specVersion&gt;
                      &lt;outputDirectory&gt;target/classes&lt;/outputDirectory&gt;
                  &lt;/configuration&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;generate-scr-scrdescriptor&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;scr&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>HelloWorld Implementation class</p>
  
  <pre><code>package com.liveops.examples.osgi.helloworld.internal;
  
  import com.liveops.examples.osgi.helloworld.HelloWorldService;
  import org.apache.felix.scr.annotations.Service;
  import org.apache.felix.scr.annotations.Component;
  
  
  @Component
  @Service(HelloWorldService.class)
  public class HelloImpl implements HelloWorldService
  {  
      public String helloWorld(String personalization)
      {
          return "Hello " + personalization + "!";
      }
  }
  </code></pre>
  
  <p>The unit test</p>
  
  <pre><code>package com.liveops.examples.osgi.helloworld.internal;
  
  import com.liveops.examples.osgi.helloworld.HelloWorldService;
  import junit.framework.Assert;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  
  import org.ops4j.pax.exam.Option;
  import org.ops4j.pax.exam.Configuration;
  import org.ops4j.pax.exam.junit.PaxExam;
  import org.ops4j.pax.exam.util.PathUtils;
  
  import javax.inject.Inject;
  
  import static org.ops4j.pax.exam.CoreOptions.*;
  
  @RunWith(PaxExam.class)
  public class HelloImplTest
  {
      @Inject
      HelloWorldService hws;
  
      @Configuration
  
      public static Option[] configuration() throws Exception{
              return options(
                      systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN"),
                      mavenBundle("org.apache.felix", "org.apache.felix.scr", "1.6.2"),
                      bundle("reference:file:" + PathUtils.getBaseDir() + "/target/classes"),
                             junitBundles());
      }
  
      @Test
      public void testInjection()
      {
          Assert.assertNotNull(hws);
      }
  
      @Test
      public void testHelloWorld() throws Exception
      {
          Assert.assertNotNull(hws);
          Assert.assertEquals("Hello UnitTest!", hws.helloWorld("UnitTest"));
  
      }
  }
  </code></pre>