About Question enthuware.oce-ejbd.v6.2.475 :
Moderator: admin
-
- Posts: 5
- Joined: Wed Oct 23, 2013 4:51 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.475 :
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?
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?
-
- Site Admin
- Posts: 10102
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.475 :
Both are are valid. One is absolute and second is relative.
HTH,
Paul.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 5
- Joined: Wed Oct 23, 2013 4:51 pm
- Contact:
-
- Posts: 197
- Joined: Mon Jun 20, 2016 5:06 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.475 :
If we do @Resource or @Inject EJBContext in MDB, will we get EJBContext or MessageDrivenContext?
-
- Site Admin
- Posts: 10102
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.475 :
As per section 16.5.2 of EJB 3.1 specification:
So it is clear that you will get an instance of MessageDriveContext in an MDB.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.
If you like our products and services, please help us by posting your review here.
-
- Posts: 197
- Joined: Mon Jun 20, 2016 5:06 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.475 :
Problem says ejbContext is valid reference to bean's EJBContext.
-
- Site Admin
- Posts: 10102
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.475 :
And MessageDrivenContext is-a EJBContext.
If you like our products and services, please help us by posting your review here.
-
- Posts: 197
- Joined: Mon Jun 20, 2016 5:06 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.475 :
I understand, thank you.
Who is online
Users browsing this forum: No registered users and 9 guests