Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Why EJB injection is not available on J2SE?

 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EJBs are part of Java EE (Enterprise Edition), so you won't find EJB features in Java SE (Standard Edition).
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic