• 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

EJB3 Dependency Injection confusion

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi

Can we inject an ejb to a servlet given that the ejb module and web module are not packaged in an EAR but deployed in same container instance?? I am facing problems in this kind of situation.
I wonder if this is even supported or not? I am using JB0SS 5.1.

Thanks

 
Ranch Hand
Posts: 446
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you can inject EJB reference in a Servlet. In fact this is one of the few things supported as far as EJB injection is concerned.
 
Shayan Shah
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess you didnt got my question. EJB can be injected to servlet but if both web module and ejb module are in same EAR. The problem I am facing in injection is when both are not in same EAR. EJB module is deployed as JAR and web module is deployed as WAR. What about DI in this situation??
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Shayan Shah wrote:
Can we inject an ejb to a servlet given that the ejb module and web module are not packaged in an EAR but deployed in same container instance?? I am facing problems in this kind of situation.
I wonder if this is even supported or not? I am using JB0SS 5.1.



In JBoss AS, if you are deploying them as separate applications, you can get it injected using the mappedName attribute:


Without the mappedName, it's not yet supported https://jira.jboss.org/jira/browse/JBAS-6332
 
I've got no option but to sell you all for scientific experiments. Or a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic