• 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

Accessing a JavaBean within a Message-Driven EJB

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JavaBean which is being used by servlets in a web application, and I want to access this bean in a Message-Driven EJB in order to update a value in the bean (I'll want to add a message text to a Vector of Strings in the JavaBean). In the servlets I can access the bean by getting it as a ServletContext attribute, but I'm not clear as to how I can access this bean within the EJB's onMessage() method, since the EJB doesn't have access to the ServletContext.
Can someone suggest how I gain access to this bean within the EJB's onMessage() method ?
Thanks in advance for any feedback.

-James
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If i understand you correct your MDB has no reference to the bean in their MANIFEST file. Just add your class to a seperate package, reference it from your ejb.jar and then simple call the Java class. This has nothing todo with the onMessage method.
The restriction of an MDB is only that you can't call it manually (there is no component or home interface) it has to be activated by a message.
But there are no other restrictions.

Originally posted by James Adams:
I have a JavaBean which is being used by servlets in a web application, and I want to access this bean in a Message-Driven EJB in order to update a value in the bean (I'll want to add a message text to a Vector of Strings in the JavaBean). In the servlets I can access the bean by getting it as a ServletContext attribute, but I'm not clear as to how I can access this bean within the EJB's onMessage() method, since the EJB doesn't have access to the ServletContext.
Can someone suggest how I gain access to this bean within the EJB's onMessage() method ?
Thanks in advance for any feedback.

-James

 
And when my army is complete, I will rule the world! But, for now, I'm going to be happy with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic