tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <>
Subject Re: Override annotations in ejb-jar.xml for a test case
Date Wed, 08 Oct 2008 21:24:41 GMT

On Sep 22, 2008, at 5:33 AM, Marcin Kwapisz wrote:

> Hi,
> I would like to add an interceptor to my EJB but only in a test. I  
> have separate ejb-jar.xml for tests and all my EJBs are annotated.

We don't have any functionality for supplying an alternate ejb-jar.xml  
for testing purposes.  It's not a bad idea and is something we might  
be able to add after we get the 3.1 release out the door.

> When ejb-jar.xml is empty everything works fine. When I change ejb- 
> jar and add for example:
> <assembly-descriptor>
>        <interceptor-binding>
>            <ejb-name>StudentEndpointBean</ejb-name>
>            <interceptor- 
> class>pl.zsk.sos.interceptor.TestInterceptor</interceptor-class>
>        </interceptor-binding>
>    </assembly-descriptor>
> automatic configuration does not find my EJBs and I get  
> javax.naming.NameNotFoundException

This might be because the ejb-jar.xml is with the ejbs that are  

A small workaround might be to add an interceptor to your main app and  
have it look for a special system property of your creation in its  
constructor.  The system property can be the name of an interceptor  
class that it should delegate to.  If the system property is not  
specified then it does nothing.  The test case could set the special  
system property to point to pl.zsk.sos.interceptor.TestInterceptor or  
any other interceptor you wish to write for a given test case.  You  
could potentially then have an interceptor dedicated to each test case  
to help with testing yet still only have one active at a time.


View raw message