tags:

views:

488

answers:

2

The java ee 6 api has an annotation @Resource with an attribute 'lookup', however, so does the java se 6 api (here). However, since java ee 6 is dependent on java se 6, it seems you can not get at the ee version of the annotation and the 'lookup' attribute.

Is this a bug or is there some other way to use this annotation that I am missing.

TIA

+2  A: 

It's the same class in both cases (javax.annotation.Resource). It's in both sets of API docs for convenience only. Actual JavaEE 6 implementations will just use the class from JavaSE 6.

skaffman
I beg to differ. The lookup element (http://java.sun.com/javaee/6/docs/api/javax/annotation/Resource.html#lookup()) is not present in the se version.
javamonkey79
Hmm, so it does. OK, that's officially weird. I hope this isn't the JCP screwing up. Again.
skaffman
I've seen examples of the Resource lookup element used, I just can't figure out how - in every scenario I've played with it seems the compiler defaults to the se annotation class and not the ee version.
javamonkey79
@javamonkey79: That makes sense, the VM won't let its own classes be overridden without some special moves - as far as the VM in concerned, they *are* the same. It looks increasingly like a mistake in the spec.
skaffman
+3  A: 

Your JDK (and mine) doesn't have the latest version of the javax.annotation.Resource from the JSR-250. To use the latest version during compilation, you'll have to override the compiler's endorsed directory (e.g. to point to your glassfishv3 endorsed directory):

-Djava.endorsed.dirs=${GLASSFISH_HOME}/modules/endorsed
Pascal Thivent
I'll give this a try later today - if it works I'll accept and upvote.
javamonkey79
javamonkey79