title: How to test EJB with TomEE?
body: <p>I'm using TomEE with Intellij to test my EJB/JPA beans. I saw on <a href="https://stackoverflow.com/a/20635285/3026886">this answer</a> that I should use a embedded container to test. I discovered Arquillian on <a href="https://stackoverflow.com/a/12189507/3026886">this other answer</a>(from the same question) but as stated on comments, it's difficult to set it up and not user friendly, things beginners like me search for.</p>
  
  <p>Unfortunately I'm not using <code>glassfish-embedded-all</code> dependency as answered, but <code>tomee-embedded</code>. I saw on this <a href="http://tomee.apache.org/examples-trunk/jpa-hibernate/README.html" rel="nofollow noreferrer">official tutorial</a> it should use JTA as well as answered above. But why?</p>
  
  <p>Doing as last link, I was getting this error:</p>
  
  <pre><code>No EJBContainer provider available: no provider names had been found.
  </code></pre>
  
  <p>Then using a piece of code from <code>@BeforeClass</code> method from this <a href="https://stackoverflow.com/questions/12625173/ejb-testing-with-tomee-embedded-ejbcontainer-api-java-lang-classformaterror-exc">answer</a>. My test is shown below:</p>
  
  <pre><code>    Properties properties = new Properties();
      properties.setProperty(EJBContainer.PROVIDER, "tomee-embedded");
      EJBContainer container = EJBContainer.createEJBContainer(properties);
      AccountDao dao = (AccountDao) container.getContext().lookup("java:global/Test/AccountDao");
  </code></pre>
  
  <p>Where <code>Test</code> is my application name and <code>AccountDao</code> is my <code>Stateless Bean</code> that I want tested. But now I'm getting this error:</p>
  
  <pre><code>Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: PG_CLASS
  </code></pre>
  
  <p>Although I'm not using <code>HSQLDB</code>, I'm having this error. How can I correctly add some postgresql properties to correctly instantiate my Hibernate <code>entityManager</code>? Here's my <code>persistence.xml</code>:</p>
  
  <pre><code>&lt;persistence-unit name="unitName"&gt;
      &lt;provider&gt;org.hibernate.jpa.HibernatePersistenceProvider&lt;/provider&gt;
      &lt;class&gt;entity.PersistentEntity.Account&lt;/class&gt;
      &lt;properties&gt;
          &lt;property name="tomee.jpa.factory.lazy" value="true"/&gt;
          &lt;property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/&gt;
          &lt;property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost/click10"/&gt;
          &lt;property name="javax.persistence.jdbc.user" value="postgres"/&gt;
          &lt;property name="javax.persistence.jdbc.password" value="postgres"/&gt;
          &lt;property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL82Dialect"/&gt;
          &lt;property name="hibernate.show_sql" value="true"/&gt;
          &lt;property name="hibernate.format_sql" value="true"/&gt;
          &lt;property name="hibernate.hbm2ddl.auto" value="update"/&gt;
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  </code></pre>