Can someone tell me why the @EJB injection has not been implemented in J2SE, do I need to perform I JNDI look up? Or maybe I'm wrong, I do apologize in that case but explanation would be welcome anyway.
However, you can run an app in the "application client container", which is a kind of stripped-down JavaEE container. Perhaps that way you can use @EJB?
Joined: Aug 15, 2004
Injection is not available (except JPA) in JSE basically because there is no one in charge of that task. However, It is possible with JPA because that is what the JPA implementation does :-D. And if you think about it, you always have to ask for the entities instances to the JPA implementation through the API. Eg:
String id = "12345"; Employee emp = entityManager.find(Employee.class, id);
If you consider Spring, the same think happens, it means, that you have to tell: "Spring give me this component", so, it searchs for it, injects its dependencies, and retrieve it to you. Eg:
Resource res = new ClassPathResource("myBeans.xml"); BeanFactory factory = new XmlBeanFactory(res); Hello bean = (Hello)factory.getBean("hello");