users@glassfish.java.net

Re: InitialContext.lookup works but _at_Resource does not

From: Dies Koper <diesk_at_fast.au.fujitsu.com>
Date: Fri, 12 Feb 2010 22:44:31 +1100

Hi Witold, Nigel,

I might have seen the same issue today (GFv3.1 nightly of a week ago).

I have an MDB deployed and try to access it from an EJB client running
in the ACC. I use @Resource with the name attribute. Injection of the
connection factory seems to go fine, but the Destination does not.
I have JMS resource 'jms/MDBQueue' defined in the Admin Console, and
that's what I specified in the name attribute, but I get a bunch of
injection/lookup related errors.

One of the messages was the following, for which I raised issue #11545.

WARNING: enterprise.deployment.backend.invalidDescriptorMappingFailure

Others included a stacktrace with a message containing a
NullPointerException, but the stacktrace of the NPE wasn't logged.
I don't have the log here, I was planning to look at it again on Monday,
but I wonder if you've seen the same.

Thanks,
Dies


On 12/02/2010 06:40, Witold Szczerba wrote:
> 2010/2/11 Nigel Deakin<Nigel.Deakin_at_sun.com>:
>> Witold,
>>
>> Witold Szczerba wrote, on 11/02/2010 15:41:
>>>
>>> Hi there,
>>> I have problem in one of my session bean deployed on Glassfish v2.1.1.
>>> The bean is supposed to send messages to WebSphere MQ using WebSphere
>>> MQ JCA Adapter. So, in order to send a message it needs two objects:
>>> ConnectionFactory and Queue.
>>> When I look for those objects using InitialContext, everything works
>>> and messages are sent.
>>>
>>> The code below works:
>>> ----------------------------------------
>>> ConnectionFactory ivtcf = null;
>>> Queue ivtQueue = null;
>>> try {
>>> InitialContext ctx = new InitialContext();
>>> ivtcf = (ConnectionFactory) ctx.lookup("jms/IVTCF");
>>> ivtQueue = (Queue) ctx.lookup("jms/IVTQueue");
>>> } catch (NamingException ex) {
>>> throw new RuntimeException(ex);
>>> }
>>>
>>> logger.info("ivctf="+ivtcf);
>>> logger.info("ivtQueue="+ivtQueue);
>>> ----------------------------------------
>>>
>>>
>>> The problem is I cannot use @Resource injection to get rod of those
>>> InitialContext lookups and NamingExceptions:
>>> ----------------------------------------
>>> @Resource(mappedName = "jms/IVTCF")
>>> private ConnectionFactory ivtcf;
>>> @Resource(mappedName = "jms/IVTQueue")
>>> private Queue ivtQueue;
>>> ----------------------------------------
>>
>> Does it work if you try name instead of mappedName?
>>
>> @Resource(name = "jms/IVTCF")
>> private ConnectionFactory ivtcf;
>> @Resource(name = "jms/IVTQueue")
>> private Queue ivtQueue;
>>
>> Nigel
>>
>
> Yes, I forgot about that - I have tried mappedName as well, didn't
> work as well :/