i have an EAR that includes an EJB 2.1 jar and an EJB3 jar. the EJB2.1 works fine when I call it from my web application. Now I want to add a new EJB3 (in the ejb3jar) that uses JMS Queues. So I define my queues in a stateless bean:
@Stateless
@Local(AsyncJobManager.class)
public class AsyncJobManagementBean implements AsyncJobManager {
[...]
@Resource(mappedName = "jms/ResultQueue")
private Queue jobResultQueue;
@Resource(mappedName = "jms/BaseConnectionFactory")
private ConnectionFactory connectionFactory;
[...]
}
When I deploy, and when I try tu call the bean I get the following error:
+CWNEN0044E: A resource reference binding could not be found for the following resource references \[XXXXX.base.facade.AsyncJobManagementBean/jobResultQueue, XXXXX.base.facade.AsyncJobManagementBean/connectionFactory\], defined for the AsyncJobManagementBean component.+
This article says that I should be able not to specify the bindings in the ibm-blabla-bnd.xml if I do not put an ejb-jar.xml [IBM help|http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/cejb_deployejbfp.html]
Am I missing the obvious about ressource injection ?
You will still need to create a bindings file. WAS does make use of the mappedName attribute - this decision was due to the fact that the mappedName attribute is vendor-specific and is not spec-mandated to be portable.
The following link contains information on how to create a binding for JMS queues. Bindings example 2 has an example of a JMS queue which would be injected into a Message Driven Bean.
http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/topic/com.ibm.websphere.base.doc/info/aes/ae/cejb_bindingsejbfp.html
Hope this helps,
Andy
I reverted this (the ejb-jar deletion) and now I have this ibm-ejb-jar-bnd.xml:
{code}
{code}
But now I have a weird error in the EJB3 project:
"The value of the element is not specified" Base_EJB3/ejbModule/META-INF "Injection target: jobResultQueue"
I searched really hard for that problem, but there is very little info on google for this... I'm clueless on that one
thanks for any help
What happens if you delete the ejb-jar.xml and just use annotations and the ibm-ejb-jar-bnd.xml file? This should work (assuming the session and ref names are correct).
Hope this helps,
Andy
# not having the ejb-jar.xml tells WebSphere to use pure annotations
# Since Websphere don't use the mappedName attribute of the @Resource, it needs the ibm-ejb-jar-bnd.xml file for the bindings.
Too bad it does'nt use the mapped name. This would improve a bit the ease of use and would centralize the information.
Thanks very much for helping.
regards
Francis
I'm glad its working now, and I completely agree. FWIW, the next version of the EE spec is planning to use a portable naming syntax so that EJBs, resources, etc. will be bound to the same place in all vendor's app servers (i.e. java:global/appName/moduleName/ejbName!interfaceName or something similar). Hopefully this direction will mean that mappedName becomes portable too - or at least that WAS will support resource injections without the XML file...
Later,
Andy