tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <>
Subject Re: Injection fails in any class that didn't instantiate an embedded ejb container
Date Fri, 17 Feb 2012 06:23:53 GMT
There's a little bit of magic we have to see who called the EJBContainer and add that class
to the application as a @ManagedBean.  Not really magic actually -- we create an exception
and then trim the call stack.

The alternative is to simply add @javax.annotation.ManagedBean to your test classes.  This
will make it a "component" by Java EE rules and that effectively gives us permission to allow
its annotations to populate JNDI and make sure what it needs has been created and is part
of the app.

Thanks so much for asking this question.  Ideally all exceptions would tell you how to proceed
with getting the desired outcome :)

I've updated the error message that is printed with NoInjectionMetaDataException so that it
says "Annotate your class with @ManagedBean".

If you encounter anything else like that, definitely continue to let us know!


On Feb 16, 2012, at 6:43 PM, afryer wrote:

> I am writing unit test cases for a group of stateless session ejbs and to
> speed up test case execution, I want to create the embedded ejb container
> once and use it across all the test case classes.  
> An example of my test case structure is shown below.  Assuming MyFirstTest
> runs first, then the injection will work for MyFirstTest.  The problem is
> the injection fails for MySecondTest with the "Unable to find injection
> meta-data for..." error message.  Why does the injection work in the class
> that actually causes the EJBContainer to be instantiated and not in any
> other class?
> --
> View this message in context:
> Sent from the OpenEJB User mailing list archive at

View raw message