title: java mockito Could not create type
body: <h3>Description of Problem</h3>
  <p>I face problem when, I try codes from some <strong>mockito</strong> tutorial. Below, please see necessary codes and errors, including <strong>pom.xml</strong> and <strong>stack trace</strong>.</p>
  <hr />
  <p><strong>My pom.xml</strong></p>
  <pre><code>    &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
      &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
               xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
               xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
          &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      
          &lt;groupId&gt;com.test&lt;/groupId&gt;
          &lt;artifactId&gt;service&lt;/artifactId&gt;
          &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      
          &lt;parent&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
              &lt;version&gt;2.0.5.RELEASE&lt;/version&gt;
          &lt;/parent&gt;
      
          &lt;properties&gt;
              &lt;java.version&gt;1.8&lt;/java.version&gt;
          &lt;/properties&gt;
      
          &lt;dependencies&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
                  &lt;artifactId&gt;lombok&lt;/artifactId&gt;
                  &lt;version&gt;1.18.4&lt;/version&gt;
                  &lt;scope&gt;provided&lt;/scope&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;com.h2database&lt;/groupId&gt;
                  &lt;artifactId&gt;h2&lt;/artifactId&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-starter-activemq&lt;/artifactId&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
                  &lt;artifactId&gt;activemq-broker&lt;/artifactId&gt;
              &lt;/dependency&gt;
      
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
                  &lt;scope&gt;test&lt;/scope&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.25.1&lt;/version&gt;
                  &lt;scope&gt;test&lt;/scope&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
                  &lt;version&gt;2.1.1.RELEASE&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;!-- https://mvnrepository.com/artifact/org.liquibase/liquibase-maven-plugin --&gt;
              &lt;!--&lt;dependency&gt;--&gt;
                  &lt;!--&lt;groupId&gt;org.liquibase&lt;/groupId&gt;--&gt;
                  &lt;!--&lt;artifactId&gt;liquibase-maven-plugin&lt;/artifactId&gt;--&gt;
                  &lt;!--&lt;version&gt;3.6.2&lt;/version&gt;--&gt;
              &lt;!--&lt;/dependency&gt;--&gt;
      
          &lt;/dependencies&gt;
      
          &lt;build&gt;
              &lt;plugins&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                      &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
                  &lt;/plugin&gt;
              &lt;/plugins&gt;
          &lt;/build&gt;
      
      &lt;/project&gt;
  </code></pre>
  <h3>My test:</h3>
  <pre><code>    import com.google.common.base.Charsets;
      import com.google.common.io.Resources;
      import org.junit.Test;
      import org.mockito.Mock;
      import java.util.Iterator;
      import static org.junit.Assert.assertEquals;
      import static org.mockito.ArgumentMatchers.any;
      import static org.mockito.ArgumentMatchers.anyInt;
      import static org.mockito.Mockito.mock;
      import static org.mockito.Mockito.when;
      
      public class ParserTest {
      
          @Test
          public void update() throws IOException {
              Iterator i = mock(Iterator.class);
              when(i.next()).thenReturn(&quot;Hello&quot;).thenReturn(&quot;World&quot;);
              String result = i.next()+&quot; &quot;+i.next();
              assertEquals(&quot;Hello World&quot;, result);
          }
      }
  </code></pre>
  <hr />
  <h3>My Stack Trace:</h3>
  <p>Stack trace is as follows:</p>
  <pre><code>org.mockito.exceptions.base.MockitoException: 
  
  Mockito cannot mock this class: interface java.util.Iterator.
  
  Mockito can only mock non-private &amp; non-final classes.
  If you're not sure why you're getting this error, please report to the mailing list.
  
  
  Java               : 1.8
  JVM vendor name    : Oracle Corporation
  JVM vendor version : 25.162-b12
  JVM name           : Java HotSpot(TM) 64-Bit Server VM
  JVM version        : 1.8.0_162-b12
  JVM info           : mixed mode
  OS name            : Windows 10
  OS version         : 10.0
  Underlying exception : java.lang.IllegalArgumentException: Could not create type
  </code></pre>
  <hr />
  <h3>My Questions:</h3>
  <ul>
  <li><p>Any idea what can be reason for this behavior?</p>
  </li>
  <li><p>How do I solve this problem?</p>
  </li>
  </ul>