@EJB Injection use or not ? Portable or not ?
I test a simple EJB in OC4J and JBoss, both have problems to use dependecy Injection with EJB.
I test dependency injection in a JSF managed bean and.
The @EJB(name="application/EJBX/local")
run in JBoss and the address of EJB is "application/EJBX/remote or local"
To return this object by lookup eg. ctx.lookup("application/EJBX/remote")
In Oracle Dependency Injection not Run("i cannot success in this") and the lookup is ctx.lookup("EJBX")...
Using ejb-ref in web.xml this is possible maping the name of EJB in Oracle simple using only <remote> and <ejb-ref-name> for use in a ManagedBean but in JBoss is not possible the same cannot resolve web.xml requires more files and parameters.
How really work ejb-ref now ? is portable ? depends of a vendor config files ?
Now i use or not DependencyInjection ?
This is portable for all JEE servers or now is imature ?
I look for glassfish and the same in first looking is the best but i cannot use glassfish now in my project.
Use a ServiceLocator and configuration files is the best solution or return to use a server configurator xml files is the best ?
what sugests ?
Please help me.
Message was edited by:
Solrac
Message was edited by:
Solrac
[1316 byte] By [
Solraca] at [2007-11-27 9:49:39]

# 1
The name() parameter for @EJB is not a global JNDI name. It merely specifies the location of the
dependency within the declaring component's private naming environment.name() is equivalent
to ejb-ref-name.The portable way to retrieve the ejb dependency defined by
@EJB(name="application/EJBX/local") is
new InitialContext().lookup("java:comp/env/application/EJBX/local")
You can find more on the relationship between @EJB and ejb-ref/ejb-local-ref in our EJB FAQ :
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#EJB_ejb-ref_ejb_local_ref
# 2
Ksaks, this information:
"The @EJB annotation and the ejb-ref/ejb-local-ref .xml elements are used to specify the same semantic information."
The behavior explained in your doc reference is part of JEE SPEC ? this behaviour is expected for all JEE servers ?
What is considered a managed componentes, Servlets, EJBs Managed Beans ?
My problem is if i use a dependency injection and the behaviour is not portable for all servers.
I have problems now using dependency injection with Oracle OC4J and Jboss.
In Oracle Injection works in servlets but not in JSF/Managed Beans and in Jboss the Injection works in JSF/ManagedBens but not in Servlets.
thanks a lot.
# 3
Yes, @EJB and ejb-ref/ejb-local-ref behavior are defined by the Java EE specifications. The only
part that is not required to be supported is the mappedName() attribute.
Yes, managed components are classes whose lifecycle is managed by the container. There is
a list of classes required to support injection in the Java EE 5 specification.
Injection is required to be supported in both servlet classes and JSF managed beans. If it's not
working it's either a bug in the Java EE 5 implementation or a configuration problem.You should
also check whether the Java EE implementation you are using has passed the Java EE 5 certification.
If not, support for the full set of injection might not have been implemented yet.