Can you take a look at this bug:
https://glassfish.dev.java.net/issues/show_bug.cgi?id=525
and see if you are affected by that? It has a lot of details to deal
with incorrect error message. But take a look at the following comment
made by Ken Saks in that bug:
/------- Additional comments from ksak <mailto:ksak_at_dev.java.net> Mon
Apr 3 17:11:48 +0000 2006 -------/
The NullPointerException is due to a bug in the way the delegateInfo data member is initialized.
delegateInfo is initialized in the EntityManagerFactoryWrapper.init() method after the physical
EntityManagerFactory lookup occurs. The NPE happens when the first access of a container-managed
entity manager object is one of the following methods { find, getReference, createQuery,
createNamedQuery, createNativeQuery } and the container-managed entity manager is not able to
correctly resolve the unitName/default to a valid physical EntityManagerFactory. This could either
happen because the given unitName is incorrect or because the corresponding physical
EntityManagerFactory was not initialized for some reason. In such cases, an IllegalStateException is
thrown from init().
Because the IllegalStateException thrown from init(), delegateInfo is not initialized. However, that
variable is accessed within a finally block in each of the EntityManager methods listed above. That
results in a NullPointerException that supercedes the IllegalStateException. The fix would be to
initialize delegateInfo earlier in init() or when the wrapper instance is created.
Note that even after this fix, the caller will still receive a runtime exception in this case. The only
difference will be that it's IllegalStateException instead of NullPointerException.
Thanks,
Sahoo
Bob Treacy wrote:
> BobTreacy:~/VDCPrototype/dist bobtreacy$ jar tf
> VDCPrototype.ear
> META-INF/
> META-INF/MANIFEST.MF
> jar/
> J2EE.dpf
> META-INF/application.xml
> META-INF/sun-application.xml
> VDCPrototype-ejb.jar
> VDCPrototype-war.war
> BobTreacy:~/VDCPrototype/dist bobtreacy$
>
> There is no ejb-jar.xml, only sun-ejb-jar.xml which is
> basically empty. I am using NetBeans 5.5 to generate
> much of this
>
>
> --- Sanjeeb Kumar Sahoo <Sanjeeb.Sahoo_at_Sun.COM> wrote:
>
>
>> Thanks for that output. I am trying to find out why
>> that warning
>> appeared. Can you please do a jar tf on
>> VDCPrototype.ear and send the
>> output? Secondly, do you have an ejb-jar.xml in
>> VDCPrototype-ejb.jar?
>> What is *version* attribute set there? Is it 3.0 or
>> not?
>>
>> Thanks,
>> Sahoo
>>
>> Bob Treacy wrote:
>>
>>> BobTreacy:~/VDCPrototype/dist bobtreacy$
>>> ~/glassfish/bin/verifier VDCPrototype.ear
>>> WARNING: DPL5400:Exception occurred : error in
>>> opening zip file.
>>> INFO: Verifying: [ VDCPrototype.ear ]
>>> INFO: Verifying: [ VDCPrototype-ejb_jar ]
>>> Visiting non-standard Signature object
>>> Visiting non-standard Signature object
>>> INFO: Verifying: [ VDCPrototype-war_war ]
>>> INFO: Compiling JSPs in [ VDCPrototype-war_war ]
>>> Visiting non-standard Signature object
>>> Visiting non-standard Signature object
>>> INFO:
>>> # of Failures : 0
>>> # of Warnings : 0
>>> # of Errors : 0
>>> INFO: No errors found in the archive.
>>> BobTreacy:~/VDCPrototype/dist bobtreacy$
>>>
>>>
>>> --- Sanjeeb Kumar Sahoo <Sanjeeb.Sahoo_at_Sun.COM>
>>>
>> wrote:
>>
>>>
>>>
>>>> Looks like entity manager was not injected at
>>>>
>> all.
>>
>>>> Have you verified
>>>> your app? Run this command to verify:
>>>> $GLASSFISH_HOME/bin/verifier <ear/jar/war file>
>>>>
>>>> Thanks,
>>>> Sahoo
>>>> Bob Treacy wrote:
>>>>
>>>>
>>>>> I am just getting started with Glassfish and
>>>>>
>> EJB3.
>>
>>>>> What could be causing the first line of
>>>>>
>> findAll()
>>
>>>>> below to be generating a NullPointerException?
>>>>>
>>>>> @Stateless
>>>>> public class StudyFacade implements
>>>>>
>>>>>
>>>> StudyFacadeLocal {
>>>>
>>>>
>>>>> @PersistenceContext
>>>>> private EntityManager em;
>>>>> ...
>>>>> public List findAll() {
>>>>> Query q = em.createQuery("SELECT
>>>>>
>> object(s)
>>
>>>>> from Study as s");
>>>>> ..
>>>>>
>>>>> }
>>>>>
>>>>> Thanks,
>>>>> Bob Treacy
>>>>>
>>>>>
>>>>>