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

Moderator: admin

Post Reply
Flavio
Posts: 5
Joined: Wed Oct 23, 2013 4:51 pm
Contact:

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

Post by Flavio » Sat Nov 02, 2013 11:54 pm

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?

admin
Site Admin
Posts: 8243
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Sun Nov 03, 2013 7:09 am

Both are are valid. One is absolute and second is relative.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Flavio
Posts: 5
Joined: Wed Oct 23, 2013 4:51 pm
Contact:

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

Post by Flavio » Sun Nov 03, 2013 4:11 pm

thank you!

johnlong
Posts: 185
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong » Sat Jun 03, 2017 9:07 am

If we do @Resource or @Inject EJBContext in MDB, will we get EJBContext or MessageDrivenContext?

admin
Site Admin
Posts: 8243
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Sat Jun 03, 2017 9:47 pm

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.
If you like our products and services, please help us by posting your review here.

johnlong
Posts: 185
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong » Sat Jun 10, 2017 9:00 am

Problem says ejbContext is valid reference to bean's EJBContext.

admin
Site Admin
Posts: 8243
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Sat Jun 10, 2017 11:49 pm

And MessageDrivenContext is-a EJBContext.
If you like our products and services, please help us by posting your review here.

johnlong
Posts: 185
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong » Sun Jun 11, 2017 9:12 am

I understand, thank you.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests