users@glassfish.java.net

Re: createQuery() NPE

From: ludo <Ludovic.Champenois_at_Sun.COM>
Date: Tue, 06 Jun 2006 13:15:59 -0700

Jason Lee wrote:
> Well, I thought I could whip this one on my own, but I'm just not
> having a very good day so far. :P I have the EM now injected
> correctly, but when I call em.createQuery("select j from Job j"); i
> get a NPE. Job is an annotated class (@Entity, @Table, @Id and
> Serializable, fwiw) in the same package as the PU file, which also
> references the class explicitly. em.isOpen() returns true, but any
> other call on the object results in an NPE. It has to be something
> subtle I'm missing, as some working code we have looks extremely similar.

Obviously, for such 'subtil' issues, we need much more than 'I get a
NPE' description...
Maybe you could 'google' this exception to see if it is mentioned somewhere.
Using tools like NetBeans 5.5 can also avoid many common mistakes.
You can also run the verifier tool to track advanced errors
(.../bin/verifier(.bat/.sh) archivename). The verifier tool is also in
NetBeans 5.5.

I am not sure why you say 'same package as the PU file...' The PU file
should not be in a package, but in in a META-INF dir.

Ludo

> I'm just having trouble tracking it down. Anyone have any quick
> hints off the top of their head? Thanks!
>
> --
> Jason Lee
> Programmer/Analyst
>