tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From afryer <apfr...@hotmail.com>
Subject Re: Injection fails in any class that didn't instantiate an embedded ejb container
Date Fri, 17 Feb 2012 12:24:51 GMT
I'm using openejb-core 4.0.0-beta-1 for my test cases.

I was using @javax.annotation.ManagedBean but i haven't managed to get it to
work yet.  I'll keep trying tomorrow though.

I was aware that creating and destroying an EJBContainer per test case
removed the need for any annotations such as @ManagedBean or @LocalClient
but it also slows down the test case execution significantly.  I only have
stateless ejbs and so don't need to recreate the container for each test
case class.  I do have a DataSource resource created in the ejb container
but i blow away and rebuild the schema and repopulate it with data before
each test case rather than recreating the entire embedded ejb container.

Now that I have this working using @LocalClient, my test cases run
significantly faster, so i'm happy with the outcome.  I still wish it was
possible to inject using the @Inject annotation.  After reading your reply
saying @Inject should be possible, i retested it but it doesn't work. 
Nothing gets injected and i end up with NullPointerExceptions.

I'm sure there's a very good reason you can't inject into any class instance
that isn't annotated with @LocalClient or @ManagedBean .  Could anyone tell
me what it is because its something i've found myself wanting to do on a
couple of occasions now but always get thwarted by the "could not find meta
data" exception.  For example, i created a Servlet test case using HttpUnit
and i wanted to inject ejbs from an embedded tomee container into an
instance of a servlet that i created, but couldn't.


--
View this message in context: http://openejb.979440.n4.nabble.com/Injection-fails-in-any-class-that-didn-t-instantiate-an-embedded-ejb-container-tp4396189p4397059.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Mime
View raw message