I have been working through a JBoss (5.0.0.CR2) example using the tutorial at
http://www.netbeans.org/kb/55/ejb30-jboss.html#Exercise_5 (however using
Netbeans 6.5).
I have an entity set up and upon deployment it is creating the table on the
database. My problem is when I try to use a SLSB as a facade to retrieve
entities back from the database. The generated code is as follows:
| @Stateless
| public class CustomerFacade implements CustomerFacadeLocal {
| @PersistenceContext
| private EntityManager em;
|
| public void create(Customer customer) {
| em.persist(customer);
| }
|
| public void edit(Customer customer) {
| em.merge(customer);
| }
|
| public void remove(Customer customer) {
| em.remove(em.merge(customer));
| }
|
| public Customer find(Object id) {
| return em.find(Customer.class, id);
| }
|
| public List findAll() {
| return em.createQuery("select object(o) from Customer as
o").getResultList();
| }
|
| }
Unfortunately when I run this code, I get a NullPointerException upon usage of
em because the PersistenceContext isn't being injected (I presume). This I'm
sure is a config error, however I have also tried @PersistenceUnit(unitName
= "PrototypeCRMSystem-ejbPU")
| private EntityManagerFactory emf;
|
| private EntityManager em = emf.createEntityManager(); which gives the
same problem when accessing emf.
My persitence.xml is as follows:
| 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";>
|
| org.hibernate.ejb.HibernatePersistence
| java:/OracleDS
|
|
|
|
|
|
|
|
Am I missing something configuration-wise or is there a problem?
Thanks
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4199064#4199064
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4199064
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user