Page 1 of 1

Re: About Question enthuware.oce-ejbd.v6.2.475 :

Posted: Sat Nov 02, 2013 11:54 pm
by Flavio
There is a problem with the question, the ejbContext is a valid reference to the bean's EJBContext.

Therefore code below:
DataSource ds1 = (DataSource)ejbContext.lookup("java:comp/env/db1");
DataSource ds1 = (DataSource)ejbContext.lookup("java:comp/env/db2");

Should have been:
DataSource ds1 = (DataSource)ejbContext.lookup("db1");
DataSource ds1 = (DataSource)ejbContext.lookup("db2");

right?

Re: About Question enthuware.oce-ejbd.v6.2.475 :

Posted: Sun Nov 03, 2013 7:09 am
by admin
Both are are valid. One is absolute and second is relative.

HTH,
Paul.

Re: About Question enthuware.oce-ejbd.v6.2.475 :

Posted: Sun Nov 03, 2013 4:11 pm
by Flavio
thank you!

Re: About Question enthuware.oce-ejbd.v6.2.475 :

Posted: Sat Jun 03, 2017 9:07 am
by johnlong
If we do @Resource or @Inject EJBContext in MDB, will we get EJBContext or MessageDrivenContext?

Re: About Question enthuware.oce-ejbd.v6.2.475 :

Posted: Sat Jun 03, 2017 9:47 pm
by admin
As per section 16.5.2 of EJB 3.1 specification:
The Container Provider is responsible for providing an appropriate EJBContext object to the referencing component. The object returned must be of the appropriate specific type for the bean requesting injection or performing the lookup—that is, the container provider must return an instance of the SessionContext interface to referencing session beans and an instance of the MessageDrivenContext interface to message-driven beans.
So it is clear that you will get an instance of MessageDriveContext in an MDB.

Re: About Question enthuware.oce-ejbd.v6.2.475 :

Posted: Sat Jun 10, 2017 9:00 am
by johnlong
Problem says ejbContext is valid reference to bean's EJBContext.

Re: About Question enthuware.oce-ejbd.v6.2.475 :

Posted: Sat Jun 10, 2017 11:49 pm
by admin
And MessageDrivenContext is-a EJBContext.

Re: About Question enthuware.oce-ejbd.v6.2.475 :

Posted: Sun Jun 11, 2017 9:12 am
by johnlong
I understand, thank you.