on 07-10-2007 11:09 AM
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?
Hi Mathias,
Please have a closer look at the exception, there is probably a "Caused by" exception that gives further information.
As you did not specify the name of the data source in your persistence.xml, my guess would be that the data source cannot be found. If you don't specify a data source explicitly, a vendor specific default name is assumed (in our case "JPA_DEFAULT"), which is usually not present in the system. The recommended way would be to specify the name of a data source alias in the persistence.xml file using the
<jta-data-source>
tag and to deploy that data source alias (which should point to an existing data source) together with your application.
Hope that helps.
Best regards,
Sabine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sabine,
thanks for your response. The data-source reference was exactly what was missing.
Regards,
Mathias
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.