Re: Injection fails in any class that didn't instantiate an embedded ejb container
+1 2012/2/17 Romain Manni-Bucau rmannibu...@gmail.com Beta 2 is gold, next will be diamond ;) Le 17 févr. 2012 19:09, David Blevins david.blev...@gmail.com a écrit : On Feb 17, 2012, at 5:08 AM, afryer wrote: Just upgraded to beta-2 and now @ManagedBean works. I had to change the context I was binding to, to get this to work. Using @LocalClient i had to bind using this code... Using @ManagedBean i have to bind like this... That difference doesn't bother me at all. Just putting it here for reference in case other people have the same issue. Now using @ManagedBean the @Inject annotation is working :) Note, the code chunks didn't come through. Looks like a potentially good page for the documentation :) The upgrade to beta-2 is gold. The next release should have some good speed improvements too. The simple-stateless example is finally starting to run in under a second on my machine again. -David
Re: Injection fails in any class that didn't instantiate an embedded ejb container
I didn't know about the @ManagedBean annotation. I got it to work using the @LocalClient annotation and creating an empty META-INF/application-client.xml file. What's the difference between @ManagedBean and @LocalClient? I just tried using @ManagedBean but i still got the same error as before (could not find meta data...). I did find that using @LocalClient i couldn't inject into my test case classes using the @Inject annotation. I had to use @EJB instead. -- View this message in context: http://openejb.979440.n4.nabble.com/Injection-fails-in-any-class-that-didn-t-instantiate-an-embedded-ejb-container-tp4396189p4396984.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Injection fails in any class that didn't instantiate an embedded ejb container
localclient or managedbean should do about the same, which managedbean annotation did you use i think javaee-api contain different version (multiple package). @Inject should work too. You can Simply close your container by test class ; typically you start it in BeforClass in each test class and close it after tests (AfterClass). Doing it you'll not need localclient or managedbean at all. - Romain 2012/2/17 afryer apfr...@hotmail.com I didn't know about the @ManagedBean annotation. I got it to work using the @LocalClient annotation and creating an empty META-INF/application-client.xml file. What's the difference between @ManagedBean and @LocalClient? I just tried using @ManagedBean but i still got the same error as before (could not find meta data...). I did find that using @LocalClient i couldn't inject into my test case classes using the @Inject annotation. I had to use @EJB instead. -- View this message in context: http://openejb.979440.n4.nabble.com/Injection-fails-in-any-class-that-didn-t-instantiate-an-embedded-ejb-container-tp4396189p4396984.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Injection fails in any class that didn't instantiate an embedded ejb container
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.
Re: Injection fails in any class that didn't instantiate an embedded ejb container
hmm, maybe you should update to beta-2, we did a lot of fix about cdi. if you want fast test maybe you should have a look to ApplicationComposer. - Romain 2012/2/17 afryer apfr...@hotmail.com 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.
Re: Injection fails in any class that didn't instantiate an embedded ejb container
On Feb 17, 2012, at 5:08 AM, afryer wrote: Just upgraded to beta-2 and now @ManagedBean works. I had to change the context I was binding to, to get this to work. Using @LocalClient i had to bind using this code... Using @ManagedBean i have to bind like this... That difference doesn't bother me at all. Just putting it here for reference in case other people have the same issue. Now using @ManagedBean the @Inject annotation is working :) Note, the code chunks didn't come through. Looks like a potentially good page for the documentation :) The upgrade to beta-2 is gold. The next release should have some good speed improvements too. The simple-stateless example is finally starting to run in under a second on my machine again. -David
Re: Injection fails in any class that didn't instantiate an embedded ejb container
Beta 2 is gold, next will be diamond ;) Le 17 févr. 2012 19:09, David Blevins david.blev...@gmail.com a écrit : On Feb 17, 2012, at 5:08 AM, afryer wrote: Just upgraded to beta-2 and now @ManagedBean works. I had to change the context I was binding to, to get this to work. Using @LocalClient i had to bind using this code... Using @ManagedBean i have to bind like this... That difference doesn't bother me at all. Just putting it here for reference in case other people have the same issue. Now using @ManagedBean the @Inject annotation is working :) Note, the code chunks didn't come through. Looks like a potentially good page for the documentation :) The upgrade to beta-2 is gold. The next release should have some good speed improvements too. The simple-stateless example is finally starting to run in under a second on my machine again. -David
Injection fails in any class that didn't instantiate an embedded ejb container
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: http://openejb.979440.n4.nabble.com/Injection-fails-in-any-class-that-didn-t-instantiate-an-embedded-ejb-container-tp4396189p4396189.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Injection fails in any class that didn't instantiate an embedded ejb container
Hi, You can either add an annotation to make it managed (managedbean one for instance) or use openejb.additionnal.callers property to specify the qualified name of the test class in the map you give when you start the container. The reason it doesnt work is you dont start the container in the test class. - Romain Le 17 févr. 2012 03:44, afryer apfr...@hotmail.com a écrit : 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: http://openejb.979440.n4.nabble.com/Injection-fails-in-any-class-that-didn-t-instantiate-an-embedded-ejb-container-tp4396189p4396189.html Sent from the OpenEJB User mailing list archive at Nabble.com.