Re: Re: Re: Re: null EntityManager while calling an EJB from an EJB.
ROUMEAS Micaël <[email protected]> Tue, 01 Mar 2011 23:37:29 +0000
| Newsgroups | gmane.comp.java.objectweb.jonas |
|---|---|
| Message-ID | <[email protected]> |
Hi Florent,
Thanks for your time. your test was accurate as it allow me to find out
my mistake.
- I never used these log before. I did add the folowing lines to "
trace.properties " file:
* org.ow2.easybeans.injection DEBUG
logger.org.ow2.easybeans.injection DEBUG
org.ow2.easybeans.enhancer.injection DEBUG
logger.org.ow2.easybeans.enhancer.injection DEBUG
org.ow2.easybeans.loader DEBUG
logger.org.ow2.easybeans.loader DEBUG*
- I'm was unsure of " logger " so I did add two lines for each during
the test.
- If I did it properly, it create a long file named (on my case):
org.ow2.easybeans.gen.invocationcontext.fr.bean.ws.Ejb1.EasyBeansInvocationContextImplbeanPreDestroy$generatedPREDESTROY39797.class
with some interesting lines there. Anyway I don't want to waste your
time just for some curiosity, but if there is some documentation on it
I'll be more than happy to learn a bit more about it.
Thanks,
M Roumeas.
PS: attached file must give the log of the corrected test as I didn't
save the previous one.
Le 01/03/2011 16:49, Florent BENOIT a écrit :
> Hi,
>
> Could you :
>
> add @PersistenceContext on a setter method so you can check if the
> callback is called on your second EJB
> --> Log the injected PersistenceContext
>
> Enable in JONAS_BASE/conf/trace.properties the logger for the
> following packages :
> -> org.ow2.easybeans.enhancer.injection
> -> org.ow2.easybeans.injection
>
> And org.ow2.easybeans.loader
>
>
> And send me the log and the EJB2.class that should be present in your
> java.io.tmpdir (/tmp on Linux for Example)
>
>
> Regards,
>
> Florent
>
> ROUMEAS Micaël wrote:
>> Hi,
>>
>> Thanks for this reply. Sadly, JOnAS 5.2.0.M4 did not solve my issue.
>>
>> I did create a clear test sample but I still get the error.
>>
>> ================================
>> ** Ejb1.java:
>>
>> @EJB
>> Ejb2 otherEjb
>>
>> method1( ) { otherEjb.method2( ); }
>>
>> ================================
>> ** Ejb2.java:
>>
>> @PersistenceContext( "PU-Name" )
>> private EntityManager em
>>
>> method2( ) { em.find( MyClass.class, "findMe" ); }
>>
>> ================================
>>
>> - But I still have this NullPointerException when I call the Ejb2
>> Stateless EJB:
>> AbsTransactionInterceptor.handleContextContainerTransaction :
>> Exception (not application exception) in business method
>> java.lang.NullPointerException
>>
>>
>> Is there anything special to do to inject entityManager ?
>> @PersistenceContext
>>
>> or even
>> @PersistenceContext( "PU-Name" )
>>
>> both work only in my 1st EJB.
>>
>> Thanks for your time,
>> M Roumeas.
>>
>> Le 01/03/2011 09:53, Hans J. Prueller a écrit :
>>> I cannot really help you but I would strongly suggest that you
>>> upgrade to the latest 5.2M4 !
>>>
>>> We are using 5.2M4 with same scenario as you do - several SLSB's
>>> "linked" to each other with @EJB annotations and all of the EJB's
>>> are having an injected entityManager with @PersistenceContext and
>>> this works pretty fine for us!
>>>
>>> regards,
>>> Hans
>>>
>>> Am Dienstag, den 01.03.2011, 09:46 +0000 schrieb ROUMEAS Micaël:
>>>> Hi there,
>>>>
>>>> I'm actually using JOnAS 5.2.M3 and I have an issue with my EJBs.
>>>>
>>>> I'm trying to use an EJB from another EJB, and so far the link "EJB to
>>>> EJB" is working properly.
>>>> My issue come when my second EJB try to use an EntityManager:
>>>> @PersistenceContext
>>>> private EntityManager em = null;
>>>>
>>>> ...
>>>>
>>>> em.find( myClass.class, "findMe" );
>>>>
>>>>
>>>> The "em" is null, JOnAS crash with a null pointer exception here.
>>>>
>>>> I don't understand why. Because when I call my EJB from a servlet for
>>>> example, my entity manager "em" is not null.
>>>> "em" is null only if I call my EJB from another EJB from the same package.
>>>>
>>>> Is there any reason for this ? Or do I miss understood some basics ?
>>>>
>>>> I hope my problem is clearly explained.
>>>> Any clue or question will be more than welcome.
>>>>
>>>> Thanks for your time,
>>>> M Roumeas.
>>>>
>>>>
>>>>
>>>
>>
>
LongFileName.txt
(text/plain, 4.4 KB)
Êþº¾^@^@^@1^@©^A^@}org/ow2/easybeans/gen/invocationcontext/fr/bean/ws/Ejb1/EasyBeansInvocationContextImplbeanPreDestroy$generatedPREDESTROY39797^G^@^A^A^@^Pjava/lang/Object^G^@^C^A^@0org/ow2/easybeans/api/EasyBeansInvocationContext^G^@^E^A^@^Dbean^A^@^QLfr/bean/ws/Ejb1;^A^@
parameters^A^@^S[Ljava/lang/Object;^A^@^Fmethod^A^@^ZLjava/lang/reflect/Method;^A^@^Kinterceptor^A^@^AI^C^@^@^@^@^A^@^Linterceptor0^A^@1Lorg/ow2/jonas/ejb/easybeans/JOnASENCInterceptor;^A^@^Linterceptor1^A^@KLorg/ow2/jonas/jndi/interceptors/impl/easybeans/ResourceCheckerInterceptor;^A^@^KcontextData^A^@^OLjava/util/Map;^A^@^Gfactory^A^@^_Lorg/ow2/easybeans/api/Factory;^A^@^RinterceptorManager^A^@#Lfr/bean/ws/Ejb1InterceptorManager;^A^@^F<init>^A^@^T(Lfr/bean/ws/Ejb1;)V^A^@^C()V^L^@^Z^@^\
^@^D^@^]^L^@^G^@^H ^@^B^@^_^A^@^Ofr/bean/ws/Ejb1^G^@!^A^@^SgetEasyBeansFactory^A^@!()Lorg/ow2/easybeans/api/Factory;^L^@#^@$
^@"^@%^L^@^V^@^W ^@^B^@'^A^@^^getEasyBeansInterceptorManager^A^@%()Lfr/bean/ws/Ejb1InterceptorManager;^L^@)^@*
^@"^@+^L^@^X^@^Y ^@^B^@-^A^@!fr/bean/ws/Ejb1InterceptorManager^G^@/^A^@-getorgow2jonasejbeasybeansJOnASENCInterceptor^A^@3()Lorg/ow2/jonas/ejb/easybeans/JOnASENCInterceptor;^L^@1^@2
^@0^@3^L^@^P^@^Q ^@^B^@5^A^@Egetorgow2jonasjndiinterceptorsimpleasybeansResourceCheckerInterceptor^A^@M()Lorg/ow2/jonas/jndi/interceptors/impl/easybeans/ResourceCheckerInterceptor;^L^@7^@8
^@0^@9^L^@^R^@^S ^@^B^@;^A^@^H<clinit>^L^@^K^@^L ^@^B^@>^A^@^MgetParameters^A^@^U()[Ljava/lang/Object;^A^@^_java/lang/IllegalStateException^G^@B^A^@HOperation getParameters can only be applied on AroundInvoke interceptors^H^@D^A^@^U(Ljava/lang/String;)V^L^@^Z^@F
^@C^@G^A^@^MsetParameters^A^@^V([Ljava/lang/Object;)V^A^@HOperation setParameters can only be applied on AroundInvoke interceptors^H^@K^A^@ getMethod^A^@^\()Ljava/lang/reflect/Method;^A^@ getTarget^A^@^T()Ljava/lang/Object;^A^@^Gproceed^A^@^Sjava/lang/Exception^G^@R^L^@^M^@^N ^@^B^@T^A^@/org/ow2/jonas/ejb/easybeans/JOnASENCInterceptor^G^@V^A^@ intercept^A^@F(Lorg/ow2/easybeans/api/EasyBeansInvocationContext;)Ljava/lang/Object;^L^@X^@Y
^@W^@Z^A^@Iorg/ow2/jonas/jndi/interceptors/impl/easybeans/ResourceCheckerInterceptor^G^@\
^@]^@Z^A^@^XbeanPreDestroy$generated^L^@_^@^\
^@"^@`^A^@:Problem in interceptors. Shouldn't go in the default case.^H^@b^A^@^NgetContextData^A^@^Q()Ljava/util/Map;^L^@^T^@^U ^@^B^@f^A^@^Qjava/util/HashMap^G^@h
^@i^@^]^A^@
getFactory^A^@^HtoString^A^@^T()Ljava/lang/String;^A^@^Wjava/lang/StringBuilder^G^@n
^@o^@^]^A^@^HgetClass^A^@^S()Ljava/lang/Class;^L^@q^@r
^@^D^@s^A^@^Ojava/lang/Class^G^@u^A^@^GgetName^L^@w^@m
^@v^@x^A^@^B\.^H^@z^A^@^Pjava/lang/String^G^@|^A^@^Esplit^A^@'(Ljava/lang/String;)[Ljava/lang/String;^L^@~^@^?
^@}^@~@^A^@^Fappend^A^@-(Ljava/lang/String;)Ljava/lang/StringBuilder;^L^@~B^@~C
^@o^@~D^A^@^B[
^H^@~F^A^@^B ^H^@~H^A^@^D ^H^@~J^A^@^WList of interceptors :
^H^@~L^A^@^\(I)Ljava/lang/StringBuilder;^L^@~B^@~N
^@o^@~O^A^@^D) - ^H^@~Q^H^@V^A^@^A[^H^@~T^H^@X^A^@^B]
^H^@~W^H^@\^A^@^VCurrent interceptor :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