Forums Register Login

Accessing a JavaBean within a Message-Driven EJB

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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

 
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 497 times.
Similar Threads
I get message to queue, but not to MDB Bean. So close yet so far!
Invoking Session Bean From within MDB
Using JNDI - insight/design ideas/help needed
What exception will be thrown if ejbRemove() is called in onMessage method?
doubt about when an MDB redelivered happen's and not?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 03:30:08.