This is how they declare a resource-ref in ejb-jar.xml :
<enterprise-beans>
<session>
<ejb-name>ResourceBean</ejb-name>
<resource-ref>
<res-ref-name>jdbc/employee</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
</resource-ref>
</session>
</enterprise-beans>
at this link: http://javahowto.blogspot.ca/2006/06/5-ways-to-get-resources-in-ejb-3.html Now if I have another session bean that needs to use the same resource-ref, do I have to declare it again inside the second EJB? Or is there a workaround?
Prior to EE 6 (available in WebSphere Application Server 8.0), there is no way to share resource-ref
across EJBs. You must redeclare the resource-ref
in each EJB.
In EE 6, you can declare the resource-ref with a name such as java:module/env/jdbc/employee
, and it will be visible to all EJBs in the module (and java:app
is visible to all modules, and java:global
is visible to all apps).