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

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
PedroKowalski
Posts: 25
Joined: Thu Aug 04, 2011 10:36 am
Location: Poland
Contact:

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

Post 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!

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

PedroKowalski
Posts: 25
Joined: Thu Aug 04, 2011 10:36 am
Location: Poland
Contact:

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

Post 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!

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

jszczepankiewicz

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

Post by jszczepankiewicz »

The J6EE version introduced "lookup" attibute to the @Resource annotation!, please check if the question/s should be altered.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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. "
If you like our products and services, please help us by posting your review here.

PedroKowalski
Posts: 25
Joined: Thu Aug 04, 2011 10:36 am
Location: Poland
Contact:

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

Post by PedroKowalski »

Thanks for this clarification :-)

Jofen
Posts: 9
Joined: Mon Oct 08, 2012 10:09 am
Contact:

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

Post 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.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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!
If you like our products and services, please help us by posting your review here.

Nuno Agostinho

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

Post 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.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

Which app server did you try it on?
If you like our products and services, please help us by posting your review here.

gurpreet_asrgndu
Posts: 55
Joined: Thu Jan 03, 2013 7:51 am
Contact:

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

Post 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

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

You are right. This has now been fixed.

thank you for your feedback!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests