title: NoClassDefFoundError while creating mock object in java
body: <p>I am getting the below exception while running my test class.
   The class is trying to initialize is available with full path but at runtime gives me the error. Can anyone suggest me what I am doing wrong. Thanks in advance. </p>
  
  <pre><code>        java.lang.NoClassDefFoundError: Could not initialize class
          at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:40)
              at org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:59)
              at org.mockito.internal.creation.jmock.ClassImposterizer.createProxy(ClassImposterizer.java:111)
              at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:51)
              at org.powermock.api.mockito.internal.mockcreation.MockCreator.createMethodInvocationControl(MockCreator.java:100)
              at org.powermock.api.mockito.internal.mockcreation.MockCreator.mock(MockCreator.java:58)
              at org.powermock.api.mockito.PowerMockito.mock(PowerMockito.java:138)
          at com.idit.contact.server.manager.XXXTests_FindContactById.additionalDataNotSpecified_ShouldCallGetFullContactVO
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:68)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:312)
              at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:88)
              at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:96)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:296)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:284)
              at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:86)
              at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:209)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:148)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:122)
              at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:33)
              at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:45)
              at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
              at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:102)
              at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
              at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:42)
              at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
              at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
              at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
              at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
              at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
  
  
  
  
  
       My Test Class is:
  
          @SuppressWarnings("deprecation")
          @RunWith(PowerMockRunner.class)
          @PrepareForTest({XXX.class, SomeExceptionHandler.class})
          @PowerMockIgnore({"com.abc.XXX",
                  "org.apache.commons.logging.*",
                  "org.apache.log4j.*"})
  
          public class XXXTests_FindContactById {
  
          @Test
              public void additionalDataNotSpecified_ABC() {
  
                  XXX cdm = PowerMockito.mock(XXX.class);
  
              }
          }
  </code></pre>