users@glassfish.java.net

Re: createQuery() NPE

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Wed, 07 Jun 2006 14:13:40 -0700

Does it mean that you've resolved all the issues?

thanks,
-marina

Jason Lee wrote On 06/07/06 14:05,:
> I was probably injecting the EM at that point, but I've since switch to
> inject an EMF due to threading issues.
>
>
> --
> Jason Lee
> Programmer/Analyst
>
> -----Original Message-----
> From: Marina.Vatkina_at_Sun.COM [mailto:Marina.Vatkina_at_Sun.COM]
> Sent: Tuesday, June 06, 2006 6:49 PM
> To: users_at_glassfish.dev.java.net
> Subject: Re: createQuery() NPE
>
> Jason,
>
> EntityManagerWrapper means that you either injecting or looking up an
> EM, not creating it from EMF. Is this the case?
>
> thanks,
> -marina
>
> Jason Lee wrote:
>
>>By "package" I meant archive. It's in the META-INF/ directory of the
>>same archive (.war) that holds the classes in question.
>>
>>Unfortunately, as far as the NPE goes, I don't have much to go on.
>>Here's all I have from the server logs :
>>
>>[#|2006-06-06T15:14:33.110-0500|INFO|sun-appserver-pe9.0|javax.enterpr
>>is
>>e.system.stream.out|_ThreadID=14;_ThreadName=httpWorkerThread-8080-0;|
>>java.lang.NullPointerException
>> at
>>com.sun.enterprise.util.EntityManagerWrapper.createQuery(EntityManager
>>Wr
>>apper.java:525)
>> at
>>com.iecokc.chronos.model.dao.impl.ChronosDaoJpaImpl.getJobs(ChronosDao
>>Jp
>>aImpl.java:28)
>> at com.iecokc.chronos.test.TestBean.getJobs(TestBean.java:26)
>>
>>I can't use NetBeans, as Eclipse is the corporate standard.
>>
>>I have Googled, but not found anything of value. Of course, it's
>>likely that my choice of keywords isn't correct, so I continue to try
>>slightly different searches, but I'm not having any success thus far.
>>
>>I had forgotten about the verifier, which pointed out some issues it
>>had with my persistence.xml, which I though was spec compliant, but I
>>made the changes anyway, just to be sure. The errors still persisted
>>until I moved the entity beans, the DAO, and META-INF/persistence.xml
>>to a separate jar file in the root of the ear, at which point things
>>started working. I'm confused as to why that would have made a
>>difference. It is my understanding that it ought to work, but either
>>my understanding is flawed, or I was missing something fundamental. :|
>>
>>At any rate, I got it working. Why it works I'll leave to another
>
> day.
>
>>;)
>>
>>Thanks for your help.
>>
>>--
>>Jason Lee
>>Programmer/Analyst
>>
>>
>>________________________________
>>
>>From: Ludovic.Champenois_at_Sun.COM [mailto:Ludovic.Champenois_at_Sun.COM]
>>Sent: Tuesday, June 06, 2006 3:16 PM
>>To: users_at_glassfish.dev.java.net
>>Subject: Re: createQuery() NPE
>>
>>
>>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
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>>For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>