Any idea how to go about to debug this?
How find out what the problem really is?
/JPS



On 29 Jan, 21:55, "Constantine J Coutsoukes" <zoso...@nyc.rr.com>
wrote:
> I am not sure what comes with netbeans by default.
> However, I downloaded the full JEE package from Sun and I don't have any
> issues.
>
> -----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: Thursday, January 29, 2009 3:29 PM
> To: Java EE (J2EE) Programming with Passion!
> Subject: [java ee programming] Re: JPA Controller Classes with Netbeans 6.5
> and Glassfish
>
> Hi,
>
> The persistence.xml seems fine.
>
> I can actually make the entity classes work by initializing them
> explicitly with the following code in the class constructor, or
> elsewhere, before using the emf and utx:
>
> ...
>         if(emf==null)
>         {
>             emf = Persistence.createEntityManagerFactory
> ("WebApp03PU");
>         }
>         if (utx == null) {
>             Context ctx = new InitialContext();
>             utx = (UserTransaction) ctx.lookup("java:comp/env/
> UserTransaction");
>         }
> ...
>
> It's just that the automatic assignment doesnt work, as expected.
> There must be something more required than the steps I listed
> above...?
>
> I read somewhere that for this to work, requires you have *FULL* Java
> EE environment.
>
> Is that what you get by default when just creating a Web App in
> Netbeans with Glassfish server?
> Or is there some other option, modules, etc, that need to be enabled
> in the Project Properties?
>
> /JPS
>
> On 28 Jan, 22:58, "Constantine J Coutsoukes" <zoso...@nyc.rr.com>
> wrote:
> > 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