Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[WAS 7] Using annotation without an ejb-jar.xml ?

276 views
Skip to first unread message

fbouchard

unread,
Sep 1, 2009, 3:03:17 PM9/1/09
to
Hi,

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 ?

andymc_

unread,
Sep 1, 2009, 3:57:37 PM9/1/09
to
Hello,

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

fbouchard

unread,
Sep 1, 2009, 4:28:06 PM9/1/09
to
ok then! This is the way I got something to work a bit (it s*cks though. I thought that annotation were for this purpose. Avoid xml configurations... :( )

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

andymc_

unread,
Sep 1, 2009, 6:39:28 PM9/1/09
to
Can you post you ejb-jar.xml too? I don't believe that you need it, but it would help to see it to understand what is going wrong.

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

fbouchard

unread,
Sep 2, 2009, 8:26:48 AM9/2/09
to
Awesome! Wow! i've been struggling on this for a week... I removed the ejb-jar.xml and everytghing works as exected. I thought the ibm-ejb-jar-bnd.xml needed the ejb-jar.xml. Now I understand:

# 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

andymc_

unread,
Sep 2, 2009, 10:16:33 AM9/2/09
to
Hi 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

0 new messages