title: Unknown entity when running junit test
body: <p>I've got a Java EE Project in my eclipse and i'm using hibernate. But i don't know why when i run my Junit tests i got an unknown entity error.</p>
  
  <p>The thing is that when i run it from my tomcat server calling the method from my servlet everything go fine.</p>
  
  <pre><code>java.lang.IllegalArgumentException: Unknown entity: com.calamar.beans.Application
  at org.hibernate.jpa.spi.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:1149)
  at com.calamar.dao.ApplicationDao.addApplication(ApplicationDao.java:32)
  at com.calamar.services.ApplicationService.addApplication(ApplicationService.java:48)
  at com.calamar.test.TestApplicationService.initializeTest(TestApplicationService.java:31)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:483)
  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.RunBefores.evaluate(RunBefores.java:24)
  at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
  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.junit.runners.ParentRunner.run(ParentRunner.java:363)
  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
  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)
  </code></pre>
  
  <p>Here the class : 
      package com.calamar.beans;</p>
  
  <pre><code>import javax.persistence.*;
  
  @Entity
  @Table(name = "calamar.application")
  public class Application 
  {
      @Id 
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "application_seq_gen")
      @SequenceGenerator(name = "application_seq_gen", sequenceName = "calamar.application_id_seq",initialValue = 1, allocationSize = 1)
      private int id;
      [...]
  }
  </code></pre>
  
  <p>The code that is called on ApplicationDao.addApplication(ApplicationDao.java:32) ([...].persist(application)) : </p>
  
  <pre><code>    entityManager = entityManagerFactory.createEntityManager();
  
      entityManager.getTransaction().begin();
      entityManager.persist(application); 
      entityManager.getTransaction().commit();
  
      entityManager.close();
  </code></pre>
  
  <p>And my persistence.xml file : </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&gt;
      &lt;persistence-unit name="calamar" transaction-type="RESOURCE_LOCAL"&gt;
          &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
          &lt;class&gt;beans.Application&lt;/class&gt;
          &lt;class&gt;beans.Derogation&lt;/class&gt;
          &lt;class&gt;beans.DerogationAutre&lt;/class&gt;
          &lt;class&gt;beans.DerogationFille&lt;/class&gt;
          &lt;class&gt;beans.DerogationLinux&lt;/class&gt;
          &lt;class&gt;beans.DerogationOracle&lt;/class&gt;
          &lt;properties&gt;
              &lt;property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/&gt;
              &lt;property name="hibernate.id.new_generator_mappings" value="false"/&gt;
              &lt;property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/&gt;
              &lt;property name="hibernate.connection.url" value="..."/&gt;
              &lt;property name="hibernate.connection.username" value="..."/&gt;
              &lt;property name="hibernate.connection.password" value="..."/&gt;
          &lt;/properties&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>I hope you will find what is wrong in my code. </p>
  
  <p>Thx</p>