How to inject a singleton EJB 3.1 into another, using ejb-jar.xml ?
Issue
-
Suppose that you have the following scenario for injecting a singleton EJB into another using annotations:
- Singleton EJB bean2:
@Singleton @LocalBean public class Bean2 { /** * Default constructor. */ public Bean2() { // TODO Auto-generated constructor stub System.out.println("In Bean2"); } }- Singleton EJB bean1 having Singleton EJB bean 2 injected in it using annotation:
@Singleton @LocalBean public class Bean1 { @EJB private Bean2 bean2; } -
How to inject a singleton EJB Bean2 into another singleton EJB Bean1 , using
ejb-jar.xml?
Environment
- JBoss Enterprise Application Platform (EAP)
- 6.0.x
- 6.1.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
