Note that there are some explanatory texts on larger screens.

plurals
  1. POEntityManager injection -> NullPointerException
    primarykey
    data
    text
    <p>My project is running on Glassfish 3.0.1 I'm trying to use @PersistenceContext annotation to inject EntityManager. Here is my code:</p> <pre><code>@Stateless public class UserBean implements UserBeanRemote { @PersistenceContext(unitName = "RHDManagementPlatformPU") private EntityManager em; public UserBean() { if (this.em == null) { System.err.println("NULL"); } } ... } </code></pre> <p>In console I get error message "NULL". I already saw 5-6 topics which are similar to mine. But the only thing I understood is maybe the problem is in my persistence.xml. Here is it:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;persistence version="1.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_1_0.xsd"&gt; &lt;persistence-unit name="RHDManagementPlatformPU" transaction-type="JTA"&gt; &lt;provider&gt;oracle.toplink.essentials.PersistenceProvider&lt;/provider&gt; &lt;jta-data-source&gt;dev_magi_entities&lt;/jta-data-source&gt; &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt; &lt;properties&gt; &lt;property name="toplink.ddl-generation" value="create-tables"/&gt; &lt;/properties&gt; &lt;/persistence-unit&gt; &lt;/persistence&gt; </code></pre> <p>I'tried to find on the internet how to configure this file, but did not find where the issue could be. Maybe someone have any idea or tutorial, manual links which can help me to better understand how this beast works =)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload