Here is a good discussion on the topic. Gavin King recommends @Inject over @EJB for non remote EJBs.
http://www.seamframework.org/107780.lace
or
https://web.archive.org/web/20140812065624/http://www.seamframework.org/107780.lace
Re: Injecting with @EJB or @Inject?
- Nov 2009, 20:48 America/New_York | Link Gavin King
That error is very strange, since EJB local references should always
be serializable. Bug in glassfish, perhaps?
Basically, @Inject is always better, since:
it is more typesafe,
it supports @Alternatives, and
it is aware of the scope of the injected object.
I recommend against the use of @EJB except for declaring references to
remote EJBs.
and
Re: Injecting with @EJB or @Inject?
Nov 2009, 17:42 America/New_York | Link Gavin King
Does it mean @EJB better with remote EJBs?
For a remote EJB, we can't declare metadata like qualifiers,
@Alternative, etc, on the bean class, since the client simply isn't
going to have access to that metadata. Furthermore, some additional
metadata must be specified that we don't need for the local case
(global JNDI name of whatever). So all that stuff needs to go
somewhere else: namely the @Produces declaration.
@EJB
work for circular injection (one singleton bean and another bean needing a reference to each other)? (with reference to my answer below - i am not sure if i am doing the right thing by switching to@EJB
) – Runyon