You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by David Goodenough <da...@linkchoose.co.uk> on 2015/04/23 16:31:22 UTC

How to use embedded openejb with jax-rs methods

I notice that openejb can be used directly in places like junit tests, which
is wonderful and I (think I) understand how it might work for an EJB app.

My case is I suppose best described as half an EJB app, there is the server
end but no EJB client.  Instead I have an @Stateless EJB which has @POST
annotated methods called by JAX-RS.

In my junit tests currently I use the JAX-RS client code to call a local tomee
instance.

Is it as simple as instantiating the EJB in the way documented at:-

http://openejb.codehaus.org/embedded.html

and then wrapping object that I would have serialised using the JAX-RS 
client in a JAXBObject and calling the method on the EJB direct, or do I 
have to do something more?

I realise that I will have to fake the HttpServletRequest object that I
pass as a @Context parameter.

David

Re: How to use embedded openejb with jax-rs methods

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

add openejb-cxf-rs as dependency and JAXRS will get deployed if you
activate the associated service (ie remote service for the mode you use)

Side note: we have other testing solution these days like EJBContainer,
ApplicationComposer, Arquillian etc...all support JAXRS



Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-04-23 16:31 GMT+02:00 David Goodenough <
david.goodenough@linkchoose.co.uk>:

> I notice that openejb can be used directly in places like junit tests,
> which
> is wonderful and I (think I) understand how it might work for an EJB app.
>
> My case is I suppose best described as half an EJB app, there is the server
> end but no EJB client.  Instead I have an @Stateless EJB which has @POST
> annotated methods called by JAX-RS.
>
> In my junit tests currently I use the JAX-RS client code to call a local
> tomee
> instance.
>
> Is it as simple as instantiating the EJB in the way documented at:-
>
> http://openejb.codehaus.org/embedded.html
>
> and then wrapping object that I would have serialised using the JAX-RS
> client in a JAXBObject and calling the method on the EJB direct, or do I
> have to do something more?
>
> I realise that I will have to fake the HttpServletRequest object that I
> pass as a @Context parameter.
>
> David
>

Re: How to use embedded openejb with jax-rs methods

Posted by sgjava <sg...@gmail.com>.
I put a simple project up on my GitHub
https://github.com/sgjava/tomee-jaxrs-test that uses embedded container.
This has client timeouts working as well that Romain helped me out with.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/How-to-use-embedded-openejb-with-jax-rs-methods-tp4674576p4674578.html
Sent from the TomEE Users mailing list archive at Nabble.com.