1

I am trying to use @Resource(lookup="") to look up a resource configured in Glassfish 3.1. I am using Eclipse 3.5.

I've set -Djava.endorsed.dirs=${GLASSFISH_HOME}/modules/endorsed and added javax.annotation.jar to my projects build bath but still it doesn't compile.

I am not able to see the lookup parameter with @Resource.

Could someone help me understand why am I not getting the lookup parameter with @Resource?

skip
  • 12,193
  • 32
  • 113
  • 153

1 Answers1

2

Are you sure the javax.annotation.jar that you are using is the one for JavaEE6 (and not for a prior version), since lookup was introduced in JavaEE 6. Check the MANIFEST of that jar to confirm.

Saket
  • 45,521
  • 12
  • 59
  • 79
  • I got this jar from ${GLASSFISH_HOME}/modules/endorsed package and I am using Glassfish 3.1. MANIFEST says that its been built with jdk 1.6. – skip Sep 18 '11 at 20:52
  • I suggest you see this post - http://jaitechwriteups.blogspot.com/2011/02/resource-and-new-lookup-attribute-how.html – Saket Sep 18 '11 at 21:08
  • In that post is it not that `-Djava.endorsed.dirs=${GLASSFISH_HOME}/modules/endorsed` being set? I am using ant for building my project. But the thing is that I am not able to compile the code in eclipse because I am not getting the correct import, the JavaEE 6 `@Resource` with `lookup` parameter. What am I missing here? – skip Sep 19 '11 at 00:33
  • Could you see if you have conflicting jars (perhaps one from JDK and one from Glassfish) for Resource. You could also Ctrl-click on Resource annotation to check which jar it is being picked from. – Saket Sep 19 '11 at 04:01
  • The imported `javax.annotation.Resource` did not have the `lookup` attribute so I downloaded `javax.annotation-3.0.1-b19.jar` from http://download.java.net/maven/glassfish/org/glassfish/javax.annotation/3.0.1-b19/ and made sure that the `javax.annotation.Resource` had the `lookup` element in it using using `javax.annotation-3.0.1-b19-sources.jar`. Created a folder `endorsed` inside `${JAVA_HOME}/jre/lib` and copied the `javax.annotation-3.0.1-b19.jar` into it.Then set `-Djava.endorsed.dirs=${JAVA_HOME}/jre/lib/endorsed`.Do not have anything on the project's build bath. It compiles now. – skip Sep 20 '11 at 15:40