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

This is a discussion on [WAS 7] Using annotation without an ejb-jar.xml ? - Websphere ; 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 ...

+ Reply to Thread
Results 1 to 6 of 6

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

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

    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/infoce...loyejbfp.html]

    Am I missing the obvious about ressource injection ?

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

    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/infoce...ingsejbfp.html

    Hope this helps,

    Andy

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

    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

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

    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

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

    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

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

    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

+ Reply to Thread