users@glassfish.java.net

Re: 3.1 Embeddable EJBContainer and JPA/weaving problem

From: NBW <emailnbw_at_gmail.com>
Date: Wed, 13 Apr 2011 08:58:03 -0400

I have an embedded container working for my unit tests. At this point my
EJBs are all stateless and include PersistenceContext injection. I don't
have any special weaving properties explicitly set thought.

The one bug I ran into is that you can't create the container in a @Before
and tear it down in an @After - you have to set it up in a @BeforeClass and
tear it down in an @AfterClass or else it will throw a security related
exception. I filed a bug on this. Oh and this is with GF3.1 FCS (bld 43 I
believe). This is a PITA because it means you can't unit test in isolation,
now your class level test methods have to share the same EJBContainer
context including JPA state. Hopefully that will be fixed soon.

Arquillian is still too raw for me to investigate the time it looks like
would be needed but it sounds interesting.

I will say that none of the process I went through was well documented,
straight forward, or painless despite the EE6 is easy for developers hype.
It's easy to develop but its far from easy to set up a test environment when
you want to include container services.

-Noah

On Wed, Apr 13, 2011 at 7:58 AM, Laird Nelson <ljnelson_at_gmail.com> wrote:

> On Wed, Apr 13, 2011 at 2:28 AM, janne postilista <
> jannepostilistat_at_gmail.com> wrote:
>
>> I just don't get it. To test your ejbs you need to have the ejb
>> classes in your test classpath. But having them in your classpath
>> breaks EJBContainer deployment. How can that work?
>>
>
> I tried for over a year to get EJBContainer working properly and never
> did. My advice to you is to give up now. :-) I used the embedded Glassfish
> APIs instead. While they leak files all over the temp directory, they do
> not appear to suffer from the same weaving issues. The weaving enabled
> property does not function entirely as advertised. The Maven embedded
> glassfish plugin is the thing you want to use, I was told. Sure hope you
> use Maven. :-)
>
> The Arquillian guys (http://www.jboss.org/arquillian) think that they've
> got an embedded container working fine; I haven't tried it yet, and don't
> see how they could have.
>
> Sorry to not have better news here.
>
> Best,
> Laird
>