title: Google App Engine Data Store Unit Tests With Maven
body: <p>Trying to get my GAE 1.9.0 project's unit tests to run using maven 3.2.1.  Data Store Related Tests Fail : </p>
  
  <pre><code>java.util.ServiceConfigurationError: 
  com.google.appengine.tools.development.LocalRpcService: 
  Provider com.google.appengine.api.datastore.dev.LocalDatastoreV4Service 
  could not be instantiated: java.lang.NoClassDefFoundError: 
  com/google/apphosting/datastore/DatastoreV4$LookupRequestOrBuilder
  </code></pre>
  
  <p>I understand this means i'm missing a dependency. Can't seem to find a doc on how to properly configure my pom.xml for datastore tests. The test crashes when I call </p>
  
  <pre><code>helper.setup()
  </code></pre>
  
  <p>on the helper:</p>
  
  <pre><code>public final LocalServiceTestHelper helper = new LocalServiceTestHelper(
              new LocalDatastoreServiceTestConfig(),
              new LocalTaskQueueTestConfig(),
              new LocalBlobstoreServiceTestConfig(),
              new LocalUserServiceTestConfig()));
  </code></pre>
  
  <p>referenced: </p>
  
  <p><a href="https://developers.google.com/appengine/docs/java/tools/maven#junit_dependencies_optional" rel="noreferrer">https://developers.google.com/appengine/docs/java/tools/maven#junit_dependencies_optional</a></p>
  
  <p><a href="https://developers.google.com/appengine/docs/java/tools/localunittesting#Java_Writing_Datastore_and_memcache_tests" rel="noreferrer">https://developers.google.com/appengine/docs/java/tools/localunittesting#Java_Writing_Datastore_and_memcache_tests</a></p>
  
  <p>the test dependencies in my pom.xml</p>
  
  <pre><code>       &lt;dependency&gt;
              &lt;groupId&gt;com.google.appengine&lt;/groupId&gt;
              &lt;artifactId&gt;appengine-testing&lt;/artifactId&gt;
              &lt;version&gt;${appengine.target.version}&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.appengine&lt;/groupId&gt;
              &lt;artifactId&gt;appengine-api-stubs&lt;/artifactId&gt;
              &lt;version&gt;${appengine.target.version}&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.appengine&lt;/groupId&gt;
              &lt;artifactId&gt;appengine-api-labs&lt;/artifactId&gt;
              &lt;version&gt;${appengine.target.version}&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
              &lt;version&gt;3.2.1.RELEASE&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.11&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;spring&lt;/groupId&gt;
              &lt;artifactId&gt;spring-mock&lt;/artifactId&gt;
              &lt;version&gt;1.0.2&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>rest of the stack trace:</p>
  
  <pre><code>at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
          at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
          at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.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 java.lang.reflect.Method.invoke(Method.java:606)
          at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
          at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
          at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
          at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
          at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
      Caused by: java.lang.NoClassDefFoundError: com/google/apphosting/datastore/DatastoreV4$LookupRequestOrBuilder
          at java.lang.Class.getDeclaredConstructors0(Native Method)
          at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493)
          at java.lang.Class.getConstructor0(Class.java:2803)
          at java.lang.Class.newInstance(Class.java:345)
          at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:373)
          ... 42 more
      Caused by: java.lang.ClassNotFoundException: com.google.apphosting.datastore.DatastoreV4$LookupRequestOrBuilder
          at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
  </code></pre>