title: Spy object by Mockito in Spring
body: <p>When I try to Spy an object in my unit test,
  I got an exception.
  This is my unit test file:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(locations = { "classpath:spring/applicationContext.xml" })
  public class BookingSuperManTest {
      BookInfoParams bookInfoParams; 
      HttpAttributeParams httpAttributeParams;
      AbstractRequester requester;
      public void beforeStartTest(){
          bookInfoParams = Mockito.spy(new BookInfoParams());
          httpAttributeParams = Mockito.spy(new HttpAttributeParams());
      }
      @Test
      public void step1GoToHomePage() throws BookingException{
          beforeStartTest();
  
          requester = new Step1HomePage(bookInfoParams, httpAttributeParams);
          requester.executeRequest();
  
          Assert.assertNotNull(httpAttributeParams.getResponseGetRequest());
      }
  }
  </code></pre>
  
  <p>I got the exception at the link assign bookInfoParams spy:</p>
  
  <pre><code>java.lang.NoClassDefFoundError: org/mockito/cglib/proxy/MethodInterceptor
      at org.powermock.api.mockito.internal.mockmaker.PowerMockMaker.&lt;init&gt;(PowerMockMaker.java:43)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
      at java.lang.Class.newInstance(Class.java:379)
      at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:61)
      at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:24)
      at org.mockito.internal.configuration.plugins.PluginRegistry.&lt;init&gt;(PluginRegistry.java:13)
      at org.mockito.internal.configuration.plugins.Plugins.&lt;clinit&gt;(Plugins.java:12)
      at org.mockito.internal.util.MockUtil.&lt;clinit&gt;(MockUtil.java:23)
      at org.mockito.internal.MockitoCore.&lt;init&gt;(MockitoCore.java:40)
      at org.mockito.Mockito.&lt;clinit&gt;(Mockito.java:1103)
      at ive.core.test.webbot.book.vietjet.BookingSuperManTest.beforeStartTest(BookingSuperManTest.java:46)
      at ive.core.test.webbot.book.vietjet.BookingSuperManTest.step1GoToHomePage(BookingSuperManTest.java:54)
      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.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.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:73)
      at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
      at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:73)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:224)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:83)
      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.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:68)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:163)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
  Caused by: java.lang.ClassNotFoundException: org.mockito.cglib.proxy.MethodInterceptor
      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)
      ... 44 more
  </code></pre>
  
  <p>This is the dependencies in my pom file</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;junit&lt;/groupId&gt;
      &lt;artifactId&gt;junit&lt;/artifactId&gt;
      &lt;version&gt;4.12&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.mockito&lt;/groupId&gt;
      &lt;artifactId&gt;mockito-core&lt;/artifactId&gt;
      &lt;version&gt;2.0.44-beta&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.powermock&lt;/groupId&gt;
      &lt;artifactId&gt;powermock-api-mockito&lt;/artifactId&gt;
      &lt;version&gt;1.6.4&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.powermock&lt;/groupId&gt;
      &lt;artifactId&gt;powermock-module-junit4&lt;/artifactId&gt;
      &lt;version&gt;1.6.4&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;cglib&lt;/groupId&gt;
      &lt;artifactId&gt;cglib&lt;/artifactId&gt;
      &lt;version&gt;3.2.1&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Maybe the version is not compatible or I missed something ?</p>