Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

EJB3 - EntityManager is null (not injected?)

843830May 10 2006 — edited Dec 27 2006
Hi, I'm trying to use EntityManager from the processRequest() method of my servlet. It's declared in the fields like this
    @PersistenceContext(unitName="testunit1") EntityManager em;  
The problem is that the EntityManager object, em, is null.

My persistence.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!-- example of a default persistence.xml -->
<persistence>
   <persistence-unit name="testunit1" transaction-type="RESOURCE_LOCAL">
   <jta-data-source>java:/OracleDS</jta-data-source>
   <class>testing.Pdfinstalledfonts</class>
      <properties>
        <property name="jboss.entity.manager.jndi.name" value="java:/testunit1"/>
        <property name="jboss.entity.manager.factory.jndi.name" value="java:/testunit1Factory"/>
		 
		<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect" />
        <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
        <property name="hibernate.connection.username" value="xxxxxxx" />        
        <property name="hibernate.connection.password" value="xxxxxxx" />
        <property name="hibernate.connection.url" value="jdbc:oracle:thin:@xxxxxxx:1521:xxxxxx" />
		<property name="hibernate.ejb.autodetection" value="class" />
      </properties>
   </persistence-unit>
</persistence>
I'm using JBoss 4.0.4 CR 2
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 24 2007
Added on May 10 2006
8 comments
6,355 views