users@glassfish.java.net

Re: Embedded EJBContainer fails to instantiate when SSB is also a WebService

From: Bhakti Mehta <bhakti.mehta_at_oracle.com>
Date: Tue, 30 Aug 2011 14:26:46 -0700

Noah,
AFAIK there was no spec requirement for Embedded EjbContainer and
support for Ejb webservices. We should consider this enhancement for a
future release.

Regards,
Bhakti

N W wrote:
> Hi Bhakti -
>
> OK, that's unfortunate. I'm surprised this is unsupported given the javaee6 1st cup sample code comes with a @Singleton @WebService example. Would this sample code not work in the embedded container?
>
> Originally I had this class annotated simply as a @WebService and was injecting my EJBs. The @WebMethod was using several of these injected EJBs and propagating the results. eg.
>
> Foo myFoo = myEJB1.getFoo();
> Bar myBar = myEJB2.createBar(myFoo);
>
> However, this was causing me problems with the transaction manager because myFoo was being detached in between finding it and passing into myEJB2 since the the calling method (@WebMethod) was not part of the EJBs persistence context. So to deal with that I added @Stateless to the @WebService class. That fixed the TX issues but broke the unit tests that try to instantiate the embedded container.
>
> As a work-around I created an EJB that wraps the other EJB calls and then I have the WebService inject the 'wrapper' EJB and call the wrapper method on it. Ugly but works and now my tests work too.
>
> -Noah
>
> On Aug 30, 2011, at 3:41 PM, Bhakti Mehta wrote:
>
>
>> I checked with Marina too and as of now this is not supported for Embedded EjbContainer and Stateless Webservice . I think when packaged in a war we had a bug in 3.1 which was causing it to behave as a webapp and I suspect may be that is why it is working in 3.1 when packaged in war.
>> Regards,
>> Bhakti
>>
>
>