This is just a guess but check your persistence.xml and make sure it is
correct. Specifically the jta-data-source.

-----Original Message-----
From: java-ee-j2ee-programming-with-passion@googlegroups.com
[mailto:java-ee-j2ee-programming-with-pass...@googlegroups.com] On Behalf Of
jps
Sent: Wednesday, January 28, 2009 10:20 AM
To: Java EE (J2EE) Programming with Passion!
Subject: [java ee programming] JPA Controller Classes with Netbeans 6.5 and
Glassfish


Hi,

I am using Netbeans 6.5 with Glassfish, to build a db-driven web-
application with Spring MVC 2.5.

For the db-entities I use the commands
 "Entity Classes from database" and then
 "JPA Controller Classes from Entity Classes"
in Netbeans 6.5 to auto-generate the classes.

The auto-generated JPA Controller classes will have declarations like
these

public class MyEntityJpaController {
    @Resource
      private UserTransaction utx = null;
    @PersistenceUnit(unitName = "WebApp03PU")
      private EntityManagerFactory emf = null;
... etc ...

inserted in the beginning of the class.

>From what I have read in different places, the annotations above
should cause the utx and emf fields to be automatically assigned by
the application-server when creating the classes, but I cannot get
this to work.

What I have done in Netbeans 6.5 is:
- Create Web Application with Spring MVC 2.5 support
- Create a Persistence-unit, WebApp03PU
then used
- Entity Classes from database
- JPA Controller Classes from Entity Classes

Apparently I am then missing something further that needs to be done,
because the utx and emf fields just remain null, and never get
assigned, so I get a NullPointerException when trying to use them.

I have tried many different things I read about this, but still cannot
figure it out.

What else do I need to do?
I guess there is some XML-declarations, more annotations, or something
else I am missing for this to work?

Thanks,
JPS



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Java 
EE (J2EE) Programming with Passion!" group.
To post to this group, send email to 
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to 
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to