You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Lars-Fredrik Smedberg <it...@gmail.com> on 2014/10/03 14:19:35 UTC

Regarding @Inject vs @EJB for EJB

Hi!

I'm trying to understand how I can use @Inject to inject EJBs.

1. If I want to inject an EJB that is packaged in the WAR together with the
code trying to inject it i assume I can use @Inject, correct?
2. As 1 but the EJB is packaged in a separate ejb-jar. I assume I can still
use @Inject correct?
3. If the EJB is packaged in another WAR inside the same EAR or in another
EAR I need to use @EJB correct?
4. In case 3 how do I adress the EJB? Where can I read more about the
naming standard?

Regards
LF

-- 
Med vänlig hälsning / Best regards

Lars-Fredrik Smedberg

STATEMENT OF CONFIDENTIALITY:
The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
address(es) and may contain confidential or privileged information. If
you are not the intended recipient, please notify Lars-Fredrik Smedberg
immediately at itsmeden@gmail.com, and destroy all copies of this
message and any attachments.

Re: Regarding @Inject vs @EJB for EJB

Posted by Andy Gumbrecht <ag...@tomitribe.com>.
Basic rule these days is @inject local and use @EJB for remote beans. If in
doubt use @EJB. That gives you all transactional state guaranteed.

Andy
On 3 Oct 2014 06:31, "Alex Soto" <as...@gmail.com> wrote:

> Well I don't know exactly how EJB and CDI is managed internally by TomEE.
> But using @Inject whatever the class is will mean that the lifecycle of
> that instance will be managed by CDI container. On the other side if you
> use @EJB the bean will be managed by EJB container, and this means EJB
> lifecycle, and of course that your bean wil be transactional and you will
> be able to apply security concerns.
>
> Note that @Inject will make your bean be treated as POJO meanwhile @EJB
> will mean that your bean will be treated as Enterprise Java Bean.
>
> As I said I am not 100% sure but I think this is how it works.
>
> 2014-10-03 14:19 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
>
> > Hi!
> >
> > I'm trying to understand how I can use @Inject to inject EJBs.
> >
> > 1. If I want to inject an EJB that is packaged in the WAR together with
> the
> > code trying to inject it i assume I can use @Inject, correct?
> > 2. As 1 but the EJB is packaged in a separate ejb-jar. I assume I can
> still
> > use @Inject correct?
> > 3. If the EJB is packaged in another WAR inside the same EAR or in
> another
> > EAR I need to use @EJB correct?
> > 4. In case 3 how do I adress the EJB? Where can I read more about the
> > naming standard?
> >
> > Regards
> > LF
> >
> > --
> > Med vänlig hälsning / Best regards
> >
> > Lars-Fredrik Smedberg
> >
> > STATEMENT OF CONFIDENTIALITY:
> > The information contained in this electronic message and any
> > attachments to this message are intended for the exclusive use of the
> > address(es) and may contain confidential or privileged information. If
> > you are not the intended recipient, please notify Lars-Fredrik Smedberg
> > immediately at itsmeden@gmail.com, and destroy all copies of this
> > message and any attachments.
> >
>
>
>
> --
> +----------------------------------------------------------+
>   Alex Soto Bueno - Computer Engineer
>   www.lordofthejars.com
> +----------------------------------------------------------+
>

Re: Regarding @Inject vs @EJB for EJB

Posted by "John D. Ament" <jo...@gmail.com>.
for all intents and purposes, as long as you're using @Local/@LocalBean
@Inject should work the exact same as @EJB, regardless of
SLSB/SFSB/Singleton.  Obviously if you're in a Bean Archive you'll want to
give your SFSB a scope so that the containers work with it properly but
last time I tried this (e.g. @SessionScoped @Stateful) most containers did
random stuff.

On Fri, Oct 3, 2014 at 8:58 AM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> Well rule is simple: for @Stateless/@Singleton if CDI is enabled
> (beans.xml) @Inject = @EJB. For @Stateful @Inject only makes sense
> with a normal scope and here cdi handles the stateful lifecycle (no
> need to call @Remove).
>
> @EJB doesn't for for remote ejb excepted using TomEE specific feature
> like JndiProvider (often you use a @Produces externalizing the jndi
> properties).
>
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
> 2014-10-03 17:19 GMT+02:00 Alex Soto <as...@gmail.com>:
> > It is never late to know sth new. But then if this is TomEE specific your
> > are tight to TomEE and won t be able to run on wildfly fir example
> >
> > El divendres, 3 octubre de 2014, hwaastad <he...@waastad.org> va
> escriure:
> >
> >> ...or use @inject all over and produce your remotes :-)
> >>
> >> br hw
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://tomee-openejb.979440.n4.nabble.com/Regarding-Inject-vs-EJB-for-EJB-tp4672108p4672117.html
> >> Sent from the TomEE Users mailing list archive at Nabble.com.
> >>
> >
> >
> > --
> > Enviat amb Gmail Mobile
>

Re: Regarding @Inject vs @EJB for EJB

Posted by Romain Manni-Bucau <rm...@gmail.com>.
it should yes


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-10-06 9:13 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
> @Romain
>
> Thanks.... is @EJB with CDI-interceptors working for any App server that is
> JEE6 compatible or is it a TomEE feature?
>
> On Mon, Oct 6, 2014 at 9:02 AM, Romain Manni-Bucau <rm...@gmail.com>
> wrote:
>
>> 2014-10-06 8:38 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
>> > @Romain
>> >
>> > - Do I not need to use @Inject for EJB if I need to use CDI Interceptors
>> on
>> > the EJB?
>>
>> no
>>
>> > - When I use @Inject where can the EJB I try to inject be packaged? Same
>> > WAR, EJB-JAR inside same EAR, other WAR in same EAR, other EAR?
>> >
>>
>> same as classloader rules in theory.
>>
>> > Regards
>> > LF
>> >
>> > On Fri, Oct 3, 2014 at 5:58 PM, Romain Manni-Bucau <
>> rmannibucau@gmail.com>
>> > wrote:
>> >
>> >> Well rule is simple: for @Stateless/@Singleton if CDI is enabled
>> >> (beans.xml) @Inject = @EJB. For @Stateful @Inject only makes sense
>> >> with a normal scope and here cdi handles the stateful lifecycle (no
>> >> need to call @Remove).
>> >>
>> >> @EJB doesn't for for remote ejb excepted using TomEE specific feature
>> >> like JndiProvider (often you use a @Produces externalizing the jndi
>> >> properties).
>> >>
>> >>
>> >>
>> >> Romain Manni-Bucau
>> >> Twitter: @rmannibucau
>> >> Blog: http://rmannibucau.wordpress.com/
>> >> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> >> Github: https://github.com/rmannibucau
>> >>
>> >>
>> >> 2014-10-03 17:19 GMT+02:00 Alex Soto <as...@gmail.com>:
>> >> > It is never late to know sth new. But then if this is TomEE specific
>> your
>> >> > are tight to TomEE and won t be able to run on wildfly fir example
>> >> >
>> >> > El divendres, 3 octubre de 2014, hwaastad <he...@waastad.org> va
>> >> escriure:
>> >> >
>> >> >> ...or use @inject all over and produce your remotes :-)
>> >> >>
>> >> >> br hw
>> >> >>
>> >> >>
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://tomee-openejb.979440.n4.nabble.com/Regarding-Inject-vs-EJB-for-EJB-tp4672108p4672117.html
>> >> >> Sent from the TomEE Users mailing list archive at Nabble.com.
>> >> >>
>> >> >
>> >> >
>> >> > --
>> >> > Enviat amb Gmail Mobile
>> >>
>> >
>> >
>> >
>> > --
>> > Med vänlig hälsning / Best regards
>> >
>> > Lars-Fredrik Smedberg
>> >
>> > STATEMENT OF CONFIDENTIALITY:
>> > The information contained in this electronic message and any
>> > attachments to this message are intended for the exclusive use of the
>> > address(es) and may contain confidential or privileged information. If
>> > you are not the intended recipient, please notify Lars-Fredrik Smedberg
>> > immediately at itsmeden@gmail.com, and destroy all copies of this
>> > message and any attachments.
>>
>
>
>
> --
> Med vänlig hälsning / Best regards
>
> Lars-Fredrik Smedberg
>
> STATEMENT OF CONFIDENTIALITY:
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> address(es) and may contain confidential or privileged information. If
> you are not the intended recipient, please notify Lars-Fredrik Smedberg
> immediately at itsmeden@gmail.com, and destroy all copies of this
> message and any attachments.

Re: Regarding @Inject vs @EJB for EJB

Posted by Lars-Fredrik Smedberg <it...@gmail.com>.
@Romain

Thanks.... is @EJB with CDI-interceptors working for any App server that is
JEE6 compatible or is it a TomEE feature?

On Mon, Oct 6, 2014 at 9:02 AM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> 2014-10-06 8:38 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
> > @Romain
> >
> > - Do I not need to use @Inject for EJB if I need to use CDI Interceptors
> on
> > the EJB?
>
> no
>
> > - When I use @Inject where can the EJB I try to inject be packaged? Same
> > WAR, EJB-JAR inside same EAR, other WAR in same EAR, other EAR?
> >
>
> same as classloader rules in theory.
>
> > Regards
> > LF
> >
> > On Fri, Oct 3, 2014 at 5:58 PM, Romain Manni-Bucau <
> rmannibucau@gmail.com>
> > wrote:
> >
> >> Well rule is simple: for @Stateless/@Singleton if CDI is enabled
> >> (beans.xml) @Inject = @EJB. For @Stateful @Inject only makes sense
> >> with a normal scope and here cdi handles the stateful lifecycle (no
> >> need to call @Remove).
> >>
> >> @EJB doesn't for for remote ejb excepted using TomEE specific feature
> >> like JndiProvider (often you use a @Produces externalizing the jndi
> >> properties).
> >>
> >>
> >>
> >> Romain Manni-Bucau
> >> Twitter: @rmannibucau
> >> Blog: http://rmannibucau.wordpress.com/
> >> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> >> Github: https://github.com/rmannibucau
> >>
> >>
> >> 2014-10-03 17:19 GMT+02:00 Alex Soto <as...@gmail.com>:
> >> > It is never late to know sth new. But then if this is TomEE specific
> your
> >> > are tight to TomEE and won t be able to run on wildfly fir example
> >> >
> >> > El divendres, 3 octubre de 2014, hwaastad <he...@waastad.org> va
> >> escriure:
> >> >
> >> >> ...or use @inject all over and produce your remotes :-)
> >> >>
> >> >> br hw
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://tomee-openejb.979440.n4.nabble.com/Regarding-Inject-vs-EJB-for-EJB-tp4672108p4672117.html
> >> >> Sent from the TomEE Users mailing list archive at Nabble.com.
> >> >>
> >> >
> >> >
> >> > --
> >> > Enviat amb Gmail Mobile
> >>
> >
> >
> >
> > --
> > Med vänlig hälsning / Best regards
> >
> > Lars-Fredrik Smedberg
> >
> > STATEMENT OF CONFIDENTIALITY:
> > The information contained in this electronic message and any
> > attachments to this message are intended for the exclusive use of the
> > address(es) and may contain confidential or privileged information. If
> > you are not the intended recipient, please notify Lars-Fredrik Smedberg
> > immediately at itsmeden@gmail.com, and destroy all copies of this
> > message and any attachments.
>



-- 
Med vänlig hälsning / Best regards

Lars-Fredrik Smedberg

STATEMENT OF CONFIDENTIALITY:
The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
address(es) and may contain confidential or privileged information. If
you are not the intended recipient, please notify Lars-Fredrik Smedberg
immediately at itsmeden@gmail.com, and destroy all copies of this
message and any attachments.

Re: Regarding @Inject vs @EJB for EJB

Posted by Romain Manni-Bucau <rm...@gmail.com>.
2014-10-06 8:38 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
> @Romain
>
> - Do I not need to use @Inject for EJB if I need to use CDI Interceptors on
> the EJB?

no

> - When I use @Inject where can the EJB I try to inject be packaged? Same
> WAR, EJB-JAR inside same EAR, other WAR in same EAR, other EAR?
>

same as classloader rules in theory.

> Regards
> LF
>
> On Fri, Oct 3, 2014 at 5:58 PM, Romain Manni-Bucau <rm...@gmail.com>
> wrote:
>
>> Well rule is simple: for @Stateless/@Singleton if CDI is enabled
>> (beans.xml) @Inject = @EJB. For @Stateful @Inject only makes sense
>> with a normal scope and here cdi handles the stateful lifecycle (no
>> need to call @Remove).
>>
>> @EJB doesn't for for remote ejb excepted using TomEE specific feature
>> like JndiProvider (often you use a @Produces externalizing the jndi
>> properties).
>>
>>
>>
>> Romain Manni-Bucau
>> Twitter: @rmannibucau
>> Blog: http://rmannibucau.wordpress.com/
>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> Github: https://github.com/rmannibucau
>>
>>
>> 2014-10-03 17:19 GMT+02:00 Alex Soto <as...@gmail.com>:
>> > It is never late to know sth new. But then if this is TomEE specific your
>> > are tight to TomEE and won t be able to run on wildfly fir example
>> >
>> > El divendres, 3 octubre de 2014, hwaastad <he...@waastad.org> va
>> escriure:
>> >
>> >> ...or use @inject all over and produce your remotes :-)
>> >>
>> >> br hw
>> >>
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://tomee-openejb.979440.n4.nabble.com/Regarding-Inject-vs-EJB-for-EJB-tp4672108p4672117.html
>> >> Sent from the TomEE Users mailing list archive at Nabble.com.
>> >>
>> >
>> >
>> > --
>> > Enviat amb Gmail Mobile
>>
>
>
>
> --
> Med vänlig hälsning / Best regards
>
> Lars-Fredrik Smedberg
>
> STATEMENT OF CONFIDENTIALITY:
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> address(es) and may contain confidential or privileged information. If
> you are not the intended recipient, please notify Lars-Fredrik Smedberg
> immediately at itsmeden@gmail.com, and destroy all copies of this
> message and any attachments.

Re: Regarding @Inject vs @EJB for EJB

Posted by Lars-Fredrik Smedberg <it...@gmail.com>.
@Romain

- Do I not need to use @Inject for EJB if I need to use CDI Interceptors on
the EJB?
- When I use @Inject where can the EJB I try to inject be packaged? Same
WAR, EJB-JAR inside same EAR, other WAR in same EAR, other EAR?

Regards
LF

On Fri, Oct 3, 2014 at 5:58 PM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> Well rule is simple: for @Stateless/@Singleton if CDI is enabled
> (beans.xml) @Inject = @EJB. For @Stateful @Inject only makes sense
> with a normal scope and here cdi handles the stateful lifecycle (no
> need to call @Remove).
>
> @EJB doesn't for for remote ejb excepted using TomEE specific feature
> like JndiProvider (often you use a @Produces externalizing the jndi
> properties).
>
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
> 2014-10-03 17:19 GMT+02:00 Alex Soto <as...@gmail.com>:
> > It is never late to know sth new. But then if this is TomEE specific your
> > are tight to TomEE and won t be able to run on wildfly fir example
> >
> > El divendres, 3 octubre de 2014, hwaastad <he...@waastad.org> va
> escriure:
> >
> >> ...or use @inject all over and produce your remotes :-)
> >>
> >> br hw
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://tomee-openejb.979440.n4.nabble.com/Regarding-Inject-vs-EJB-for-EJB-tp4672108p4672117.html
> >> Sent from the TomEE Users mailing list archive at Nabble.com.
> >>
> >
> >
> > --
> > Enviat amb Gmail Mobile
>



-- 
Med vänlig hälsning / Best regards

Lars-Fredrik Smedberg

STATEMENT OF CONFIDENTIALITY:
The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
address(es) and may contain confidential or privileged information. If
you are not the intended recipient, please notify Lars-Fredrik Smedberg
immediately at itsmeden@gmail.com, and destroy all copies of this
message and any attachments.

Re: Regarding @Inject vs @EJB for EJB

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Well rule is simple: for @Stateless/@Singleton if CDI is enabled
(beans.xml) @Inject = @EJB. For @Stateful @Inject only makes sense
with a normal scope and here cdi handles the stateful lifecycle (no
need to call @Remove).

@EJB doesn't for for remote ejb excepted using TomEE specific feature
like JndiProvider (often you use a @Produces externalizing the jndi
properties).



Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-10-03 17:19 GMT+02:00 Alex Soto <as...@gmail.com>:
> It is never late to know sth new. But then if this is TomEE specific your
> are tight to TomEE and won t be able to run on wildfly fir example
>
> El divendres, 3 octubre de 2014, hwaastad <he...@waastad.org> va escriure:
>
>> ...or use @inject all over and produce your remotes :-)
>>
>> br hw
>>
>>
>>
>> --
>> View this message in context:
>> http://tomee-openejb.979440.n4.nabble.com/Regarding-Inject-vs-EJB-for-EJB-tp4672108p4672117.html
>> Sent from the TomEE Users mailing list archive at Nabble.com.
>>
>
>
> --
> Enviat amb Gmail Mobile

Re: Regarding @Inject vs @EJB for EJB

Posted by Alex Soto <as...@gmail.com>.
It is never late to know sth new. But then if this is TomEE specific your
are tight to TomEE and won t be able to run on wildfly fir example

El divendres, 3 octubre de 2014, hwaastad <he...@waastad.org> va escriure:

> ...or use @inject all over and produce your remotes :-)
>
> br hw
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Regarding-Inject-vs-EJB-for-EJB-tp4672108p4672117.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>


-- 
Enviat amb Gmail Mobile

Re: Regarding @Inject vs @EJB for EJB

Posted by hwaastad <he...@waastad.org>.
...or use @inject all over and produce your remotes :-)

br hw



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Regarding-Inject-vs-EJB-for-EJB-tp4672108p4672117.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Regarding @Inject vs @EJB for EJB

Posted by Andy Gumbrecht <ag...@tomitribe.com>.
That's right Howard. It's kind of a TomEE feature though. So what I blurted
above is the safe bet. Anything you can 'get' local  @inject, inter-app or
inter-machine use @EJB
Andy.

http://www.tomitribe.com - @AndyGeeDe - On a mobile device, and I have fat
fingers. Sorry for typos.
On 3 Oct 2014 07:55, "Howard W. Smith, Jr." <sm...@gmail.com> wrote:

> Yes, I remember when I became TomEE user, I think Romain advised me that I
> can use @Inject or @EJB. I decided to only use @EJB for EJBs and @Inject
> for @SessionScoped, @ApplicationScoped, @RequestScoped beans.
>
>
> On Fri, Oct 3, 2014 at 10:49 AM, <ka...@gmail.com> wrote:
>
> > Hi,
> > I am not sure about that Alex. I use @Inject only and Stateless and stuff
> > is  working fine
> >
> > Skickat från min iPhone
> >
> > > 3 okt 2014 kl. 15:30 skrev Alex Soto <as...@gmail.com>:
> > >
> > > Well I don't know exactly how EJB and CDI is managed internally by
> TomEE.
> > > But using @Inject whatever the class is will mean that the lifecycle of
> > > that instance will be managed by CDI container. On the other side if
> you
> > > use @EJB the bean will be managed by EJB container, and this means EJB
> > > lifecycle, and of course that your bean wil be transactional and you
> will
> > > be able to apply security concerns.
> > >
> > > Note that @Inject will make your bean be treated as POJO meanwhile @EJB
> > > will mean that your bean will be treated as Enterprise Java Bean.
> > >
> > > As I said I am not 100% sure but I think this is how it works.
> > >
> > > 2014-10-03 14:19 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
> > >
> > >> Hi!
> > >>
> > >> I'm trying to understand how I can use @Inject to inject EJBs.
> > >>
> > >> 1. If I want to inject an EJB that is packaged in the WAR together
> with
> > the
> > >> code trying to inject it i assume I can use @Inject, correct?
> > >> 2. As 1 but the EJB is packaged in a separate ejb-jar. I assume I can
> > still
> > >> use @Inject correct?
> > >> 3. If the EJB is packaged in another WAR inside the same EAR or in
> > another
> > >> EAR I need to use @EJB correct?
> > >> 4. In case 3 how do I adress the EJB? Where can I read more about the
> > >> naming standard?
> > >>
> > >> Regards
> > >> LF
> > >>
> > >> --
> > >> Med vänlig hälsning / Best regards
> > >>
> > >> Lars-Fredrik Smedberg
> > >>
> > >> STATEMENT OF CONFIDENTIALITY:
> > >> The information contained in this electronic message and any
> > >> attachments to this message are intended for the exclusive use of the
> > >> address(es) and may contain confidential or privileged information. If
> > >> you are not the intended recipient, please notify Lars-Fredrik
> Smedberg
> > >> immediately at itsmeden@gmail.com, and destroy all copies of this
> > >> message and any attachments.
> > >>
> > >
> > >
> > >
> > > --
> > > +----------------------------------------------------------+
> > >  Alex Soto Bueno - Computer Engineer
> > >  www.lordofthejars.com
> > > +----------------------------------------------------------+
> >
>

Re: Regarding @Inject vs @EJB for EJB

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
Yes, I remember when I became TomEE user, I think Romain advised me that I
can use @Inject or @EJB. I decided to only use @EJB for EJBs and @Inject
for @SessionScoped, @ApplicationScoped, @RequestScoped beans.


On Fri, Oct 3, 2014 at 10:49 AM, <ka...@gmail.com> wrote:

> Hi,
> I am not sure about that Alex. I use @Inject only and Stateless and stuff
> is  working fine
>
> Skickat från min iPhone
>
> > 3 okt 2014 kl. 15:30 skrev Alex Soto <as...@gmail.com>:
> >
> > Well I don't know exactly how EJB and CDI is managed internally by TomEE.
> > But using @Inject whatever the class is will mean that the lifecycle of
> > that instance will be managed by CDI container. On the other side if you
> > use @EJB the bean will be managed by EJB container, and this means EJB
> > lifecycle, and of course that your bean wil be transactional and you will
> > be able to apply security concerns.
> >
> > Note that @Inject will make your bean be treated as POJO meanwhile @EJB
> > will mean that your bean will be treated as Enterprise Java Bean.
> >
> > As I said I am not 100% sure but I think this is how it works.
> >
> > 2014-10-03 14:19 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
> >
> >> Hi!
> >>
> >> I'm trying to understand how I can use @Inject to inject EJBs.
> >>
> >> 1. If I want to inject an EJB that is packaged in the WAR together with
> the
> >> code trying to inject it i assume I can use @Inject, correct?
> >> 2. As 1 but the EJB is packaged in a separate ejb-jar. I assume I can
> still
> >> use @Inject correct?
> >> 3. If the EJB is packaged in another WAR inside the same EAR or in
> another
> >> EAR I need to use @EJB correct?
> >> 4. In case 3 how do I adress the EJB? Where can I read more about the
> >> naming standard?
> >>
> >> Regards
> >> LF
> >>
> >> --
> >> Med vänlig hälsning / Best regards
> >>
> >> Lars-Fredrik Smedberg
> >>
> >> STATEMENT OF CONFIDENTIALITY:
> >> The information contained in this electronic message and any
> >> attachments to this message are intended for the exclusive use of the
> >> address(es) and may contain confidential or privileged information. If
> >> you are not the intended recipient, please notify Lars-Fredrik Smedberg
> >> immediately at itsmeden@gmail.com, and destroy all copies of this
> >> message and any attachments.
> >>
> >
> >
> >
> > --
> > +----------------------------------------------------------+
> >  Alex Soto Bueno - Computer Engineer
> >  www.lordofthejars.com
> > +----------------------------------------------------------+
>

Re: Regarding @Inject vs @EJB for EJB

Posted by ka...@gmail.com.
Hi, 
I am not sure about that Alex. I use @Inject only and Stateless and stuff is  working fine

Skickat från min iPhone

> 3 okt 2014 kl. 15:30 skrev Alex Soto <as...@gmail.com>:
> 
> Well I don't know exactly how EJB and CDI is managed internally by TomEE.
> But using @Inject whatever the class is will mean that the lifecycle of
> that instance will be managed by CDI container. On the other side if you
> use @EJB the bean will be managed by EJB container, and this means EJB
> lifecycle, and of course that your bean wil be transactional and you will
> be able to apply security concerns.
> 
> Note that @Inject will make your bean be treated as POJO meanwhile @EJB
> will mean that your bean will be treated as Enterprise Java Bean.
> 
> As I said I am not 100% sure but I think this is how it works.
> 
> 2014-10-03 14:19 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
> 
>> Hi!
>> 
>> I'm trying to understand how I can use @Inject to inject EJBs.
>> 
>> 1. If I want to inject an EJB that is packaged in the WAR together with the
>> code trying to inject it i assume I can use @Inject, correct?
>> 2. As 1 but the EJB is packaged in a separate ejb-jar. I assume I can still
>> use @Inject correct?
>> 3. If the EJB is packaged in another WAR inside the same EAR or in another
>> EAR I need to use @EJB correct?
>> 4. In case 3 how do I adress the EJB? Where can I read more about the
>> naming standard?
>> 
>> Regards
>> LF
>> 
>> --
>> Med vänlig hälsning / Best regards
>> 
>> Lars-Fredrik Smedberg
>> 
>> STATEMENT OF CONFIDENTIALITY:
>> The information contained in this electronic message and any
>> attachments to this message are intended for the exclusive use of the
>> address(es) and may contain confidential or privileged information. If
>> you are not the intended recipient, please notify Lars-Fredrik Smedberg
>> immediately at itsmeden@gmail.com, and destroy all copies of this
>> message and any attachments.
>> 
> 
> 
> 
> -- 
> +----------------------------------------------------------+
>  Alex Soto Bueno - Computer Engineer
>  www.lordofthejars.com
> +----------------------------------------------------------+

Re: Regarding @Inject vs @EJB for EJB

Posted by Alex Soto <as...@gmail.com>.
Well I don't know exactly how EJB and CDI is managed internally by TomEE.
But using @Inject whatever the class is will mean that the lifecycle of
that instance will be managed by CDI container. On the other side if you
use @EJB the bean will be managed by EJB container, and this means EJB
lifecycle, and of course that your bean wil be transactional and you will
be able to apply security concerns.

Note that @Inject will make your bean be treated as POJO meanwhile @EJB
will mean that your bean will be treated as Enterprise Java Bean.

As I said I am not 100% sure but I think this is how it works.

2014-10-03 14:19 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:

> Hi!
>
> I'm trying to understand how I can use @Inject to inject EJBs.
>
> 1. If I want to inject an EJB that is packaged in the WAR together with the
> code trying to inject it i assume I can use @Inject, correct?
> 2. As 1 but the EJB is packaged in a separate ejb-jar. I assume I can still
> use @Inject correct?
> 3. If the EJB is packaged in another WAR inside the same EAR or in another
> EAR I need to use @EJB correct?
> 4. In case 3 how do I adress the EJB? Where can I read more about the
> naming standard?
>
> Regards
> LF
>
> --
> Med vänlig hälsning / Best regards
>
> Lars-Fredrik Smedberg
>
> STATEMENT OF CONFIDENTIALITY:
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> address(es) and may contain confidential or privileged information. If
> you are not the intended recipient, please notify Lars-Fredrik Smedberg
> immediately at itsmeden@gmail.com, and destroy all copies of this
> message and any attachments.
>



-- 
+----------------------------------------------------------+
  Alex Soto Bueno - Computer Engineer
  www.lordofthejars.com
+----------------------------------------------------------+