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 »

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: 8957
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

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 »

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 »

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

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

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

Post 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.
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 »

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

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

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

Post by admin »

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 »

I understand, thank you.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests