ejb@glassfish.java.net

Re: EJB reference in both EJB and Interceptor

From: Chrys Rowe <Chrys.Rowe_at_Sun.COM>
Date: Thu, 16 Oct 2008 11:35:19 -0400

Hi

Removing the name attribute seems to fix the problem.
Do you think this is a bug in Glassfish or JavaEE?

Chrys



>
>
> On Oct 16, 2008, at 8:16 AM, Chrys Rowe wrote:
>
>
>
>> I have two stateless session beans and 1 interceptor class.
>>
>> In ssBean1 I inject and use a reference to ssBean2 using the @EJB
>> notation. ssBean1 also has a method that has an @Interceptors wrapper
>> that calls the interceptor class.
>>
>> In my interceptor class I also want to use methods in ssBean2 so I
>> inject a reference using the same @EJB notation.
>>
>> The problem is that if I inject a reference to ssBean2 in both ssBean1
>> and the interceptor class then my EJB reference in the interceptor is
>> null.
>>
>> If I don't inject ssBean2 in ssBean1 then my interceptor EJB reference
>> works fine.
>>
>> I also found that if I have a ssBean3 class that doesn't reference
>> ssBean2 and calls the same interceptor before ssBean1 then the EJB
>> reference in the interceptor will work when its later called from
>> ssBean1.
>>
>> I attached the 5 sample classes that reproduce the issue.
>> If you call ssBean1.Test() a NPE is thrown in TestInterceptor. If you
>> comment out the EJB injection in ssBean1 then no NPE is thrown in
>> TestInterceptor.
>>
>
>
>> Is this a bug or am I doing something wrong?
>>
>
>
> Sounds like a bug. Can you remove the name() attribute from the @EJB
>
> annotations and see if you still get the NPE?
>
>
>
> --ken
>
>
>
>> Thanks
>> Chrys
>>
>>