• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OpenEJB, DI Overriding annotation with deployment descriptor

 
Ranch Hand
Posts: 153
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have learned that xml deployment descriptors override annotations.
So I am trying to use that feature to inject a mock implemantion into an EJB for testing:

I am using OpenEJB 3.1.2.



The CreditCardServiceBean gets injected into the TravelAgentBean

I try to override this in the ejb-jar.xml:


however testing the whole setup I see that still the CreditCardServiceBean
is injected.
Only when I remove the @EJB(beanName="CreditCardServiceBean") annotation the CreditCardServiceMock is injected.
I don't think thats the expected behavior.
Is something wrong with my deployment desprictor?
Any help would be appreciated.
 
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
Your ejb-ref-name should match the "name" of the @EJB (which by default is classname.fieldname). Try this:




ejb-jar.xml (note the ejb-ref-name now matches the name attribute of @EJB)
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good catch, Jaikiran!

A nice override/debug option is to set 'openejb.descriptors.output' to 'true'. With that on the effective runtime descriptor is saved to the temp directory. Then you can take a look to see what your xml and annotations look like combined into the final "one true" descriptor.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic