aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Why EJB injection is not available on J2SE? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Why EJB injection is not available on J2SE?" Watch "Why EJB injection is not available on J2SE?" New topic
Author

Why EJB injection is not available on J2SE?

Alessandro Ilardo
Ranch Hand

Joined: Dec 23, 2005
Posts: 218
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.

Thanks in advance


trying to decode a woman mind....
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14352
    
  22

EJBs are part of Java EE (Enterprise Edition), so you won't find EJB features in Java SE (Standard Edition).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Stephanie Hehreuer
Greenhorn

Joined: Jul 22, 2007
Posts: 4
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?
Fabian Gutierrez
Greenhorn

Joined: Aug 15, 2004
Posts: 22
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");


Best Regards.


SCJP 1.4, SCWCD 1.4, SCBCD 5, SCJD 5
 
Consider Paul's rocket mass heater.
 
subject: Why EJB injection is not available on J2SE?