title: Error java.lang.ClassNotFoundException: org.springframework.orm.jpa.EntityManagerFactoryUtils only when query didn't find any results
body: <p>I'll post my code first.</p>
  
  <pre><code>public boolean checkIfExists(String name, String surname) {
          Object m = null;
          entityManager.getTransaction().begin();
  
          Query q = entityManager.createNamedQuery(Person.findByNameSurname)
                  .setParameter("i", name).setParameter("n", surname);
  
          try {
              m = q.getSingleResult();
          } catch (Exception sqle) {
              System.out.println("SQL exception: " + sqle.getMessage());
          }
          entityManager.getTransaction().commit();
  
          if (m != null)
              return true;
  
          return false;
      }
  </code></pre>
  
  <p>Query:</p>
  
  <pre><code>@NamedQuery(name=Person.findByNameSurname, query="SELECT p FROM Person p WHERE p.name like :i AND p.surname like :n"),
  </code></pre>
  
  <p>And this code works fine it the person with name and surname really exists in database.</p>
  
  <p>If I type name or surname that's not in database I get such exception:</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.NoClassDefFoundError:
    org/springframework/orm/jpa/EntityManagerFactoryUtils     at
    org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect.ajc$afterThrowing$org_springframework_orm_jpa_aspectj_JpaExceptionTranslatorAspect$1$18a1ac9(JpaExceptionTranslatorAspect.aj:33)
      at
    pl.program.dao.PersonJpaDao.checkIfExists(PersonJpaDao.java:27)
      at pl.program.Start.test(Start.java:121)    at
    pl.program.Main.main(Main.java:11) Caused by:
    java.lang.ClassNotFoundException:
    org.springframework.orm.jpa.EntityManagerFactoryUtils     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:424)     at
    sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)     at
    java.lang.ClassLoader.loadClass(ClassLoader.java:357)     ... 4 more</p>
  </blockquote>
  
  <p>So for example if I have in database person with name - Jack and surname Black and I call </p>
  
  <pre><code>checkIfExists("Jack", "Black")
  </code></pre>
  
  <p>everything is ok. But if I just change it to </p>
  
  <pre><code>checkIfExists("Jack1", "Black")
  </code></pre>
  
  <p>I get exception mention above.</p>
  
  <p>The same problem happens to other methods like this, when record is not present in database and I want to use <code>getSingleResult()</code>. </p>
  
  <p>I tried <code>getResultList()</code> and it returns empty list.</p>
  
  <p>Do you have any ideas what can be problem here?</p>