Page 1 of 1

About Question enthuware.oce-ejbd.v6.2.419 :

Posted: Mon Aug 08, 2011 5:41 pm
by PedroKowalski
Howdy!

I was thinking about the last answer:
@Resource(lookup="jms/myTCF")
ConnectionFactory myTCF;
It is wrong because it doesn't use the java:global JNDI namespace but the relative value, right?
So if I use the "lookup" attribute JNDI location for @Resource it always have to be the global one?

Thanks in advance!

Cheers!

Re: About Question enthuware.oce-ejbd.v6.2.419 :

Posted: Wed Aug 10, 2011 5:48 am
by admin
I think it is correct because the question says, "... specified it in your message producer's environment under the name "jms/myTCF"..." Therefore, java:comp/env/jms/myTCF and jms/myTCF both are valid.

Re: About Question enthuware.oce-ejbd.v6.2.419 :

Posted: Wed Aug 10, 2011 3:15 pm
by PedroKowalski
So you think that the last one is also correct?

To be clear - I'm not telling that it should be :-)
I would just like to know why it is incorrect, as there is no explanation to this answer.

Thanks in advance!

Cheers!

Re: About Question enthuware.oce-ejbd.v6.2.419 :

Posted: Sun Aug 14, 2011 8:47 am
by admin
No, there is no attribute named "lookup", it should be "name" as in @Resource(name="jms/myTCF") This is explained in option 3.

Re: About Question enthuware.oce-ejbd.v6.2.419 :

Posted: Mon Aug 15, 2011 3:39 pm
by jszczepankiewicz
The J6EE version introduced "lookup" attibute to the @Resource annotation!, please check if the question/s should be altered.

Re: About Question enthuware.oce-ejbd.v6.2.419 :

Posted: Tue Aug 16, 2011 3:11 pm
by admin
You are right. The option is wrong because as per the API javadoc for lookup, "It can link to any compatible resource using the global JNDI names. "

Re: About Question enthuware.oce-ejbd.v6.2.419 :

Posted: Wed Aug 17, 2011 6:20 am
by PedroKowalski
Thanks for this clarification :-)

Re: About Question enthuware.oce-ejbd.v6.2.419 :

Posted: Sun Oct 14, 2012 6:45 pm
by Jofen
For Option 3, the explaination of why it is wrong says:
"The right syntax for resource injection would be:
@Resource(name="jms/myTCF")
ConnectionFactory myTCF;"

But according to 6.2.420, the name does not need to be specified, as "name" is the default attributes.
viewtopic.php?f=4&t=801
So option 3 should also be correct.

Re: About Question enthuware.oce-ejbd.v6.2.419 :

Posted: Sun Oct 14, 2012 7:31 pm
by admin
Jofen wrote:For Option 3, the explaination of why it is wrong says:
"The right syntax for resource injection would be:
@Resource(name="jms/myTCF")
ConnectionFactory myTCF;"

But according to 6.2.420, the name does not need to be specified, as "name" is the default attributes.
viewtopic.php?f=4&t=801
So option 3 should also be correct.
You are right. This has now been fixed.

thank you for your feedback!

Re: About Question enthuware.oce-ejbd.v6.2.419 :

Posted: Sun Feb 24, 2013 6:29 am
by Nuno Agostinho
Have you tried this? Resouce annotation doesn't compile without name attribute specified. So Option 3 should be
@Resource(name="jms/myTCF")
ConnectionFactory myTCF;

otherwise is not correct.

Re: About Question enthuware.oce-ejbd.v6.2.419 :

Posted: Thu Feb 28, 2013 7:15 am
by admin
Which app server did you try it on?

Re: About Question enthuware.oce-ejbd.v6.2.419 :

Posted: Thu Jul 18, 2013 8:25 am
by gurpreet_asrgndu
admin do you mind checking the last comment posted by Nuno Agostinho. because he is correct. in case of annotations if there is an attribute named value in the annotation defintion, then only can you skip writting the attribute name(if no other attributes have been specified) i.e MyAnnotation("helloworld).

i wonder why nuno hasnt been replied to since feb 24

Re: About Question enthuware.oce-ejbd.v6.2.419 :

Posted: Sat Jul 20, 2013 1:07 pm
by admin
You are right. This has now been fixed.

thank you for your feedback!