I am trying out EJB 3.0. I use RAD 8 and WebSphere application server 7. I created an Session Bean let’s call it TopSessionEJB and injected a datasoure into that bean like:
@Resource(name="myDataSource")
private javax.sql.DataSource defaultDataSource;
I update my ibm-ejb-jar-bind.xml and map the datasource to the real jndi data source name:
<session name="TopSessionEJB ">
<resource-ref name="myDataSource"
binding-name="jdbc/myRealDB">
</resource-ref>
</session>
I call the this EJB from the servlet and everything works fine.
Now if I make a subclass of TopSessionEJB, let’s call it MySubClassEJB. I deploy this updated EAR on the server, things are fine. I try to access my old Servlet from the browser which in turn calls my old TopSessionEJB, I get error in my server logs, complaining that I did not provide any resource reference for my MySubClassEJB's myDataSource.
Caused by:
com.ibm.wsspi.injectionengine.InjectionException: CWNEN0044E: A resource reference binding could not be found for the following resource references [myDataSource], defined for the MySubClassEJB component.
at com.ibm.wsspi.injectionengine.InjectionProcessor.collectInjectionNBindingData(
One would think I just need another entry in the ibm-ejb-jar-bind.xml for this subclass MySubClassEJB but if I try to do that I get RAD error that I am creating a resource reference for something that does not exist.
So the question is how do you inject a database resource-reference in the your base EJB and then inherit that datasource in all of your sub-classes.
I would appreciate if someone could help.
Thanks