Skip to Content
0
Former Member
Jul 10, 2007 at 10:09 AM

EntityManager injection fails

35 Views

Hello,

I implemented a simple enterprise application 5 and I get the following exception:

Cannot perform injection over bean instance com.sap.pep.PepBean ...
nested exception is: 
com.sap.engine.lib.injection.InjectionException: Injection on field em of instance com.sap.pep.PepBean failed. 
Could not get a value to be injected from the factory.

Following, I give parts of the code I think which is related, but I'm not really sure where to look.

persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" 
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="pep_pu"/>
</persistence>

A stateless SessionBean that is supposed to use the entity bean:

@Stateless
public class PepBean implements PepLocal {
	
     @PersistenceContext(unitName="pep_pu", type=PersistenceContextType.TRANSACTION)
     private EntityManager em;
     ...
}

The EntityBean:

@Entity
public class Requests implements Serializable {
	@Id
	private int id;
	private String subjectid;
	private String actionvalue;
	private String response;
	private String subjectvalue;
	private String resourceid;
... getters/setters 

For Database I use the MAXDB 7.6 and I set up a connection in the NWDS as described "Developing Java EE 5 Apps from Scratch" (page 8/9).

The Database Setting I use are:

Connection: CE1

Schema/UserID: SAPCE1DB

I double checked that there is the table REQUESTS in the schema SAPCE1DB. Just in case, I created a table tmp_sequence for the Auto-generator, allthough I do not use key generation.

Does anyone have an idea?