users@glassfish.java.net

org.glassfish.main.javaee-api:javax.annotation:3.1.2 has wrong Resource annotation in it?

From: Laird Nelson <ljnelson_at_gmail.com>
Date: Fri, 3 Aug 2012 13:27:55 -0700

I hope this is pilot error.

I am depending on the following Maven artifact:

<dependency>
  <groupId>org.glassfish.main.ejb</groupId>
  <artifactId>javax.ejb</artifactId>
  <version>3.1.2</version>
  <scope>provided</scope>
</dependency>

This transitively brings in:

<dependency>
  <groupId>org.glassfish.main.javaee-api</groupId>
  <artifactId>javax.annotation</artifactId>
  <version>3.1.2</version>
  <scope>provided</scope>
</dependency>

So far so good.

I tried to use the javax.annotation.Resource annotation like this:

@Resource(lookup = "java:global/yadayada")
private DataSource ds;

...making use of the "lookup" attribute documented here:
http://docs.oracle.com/javaee/6/api/javax/annotation/Resource.html#lookup()

I received a compilation error:

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/ljnelson/Projects/blah/Foo.java:[45,12] cannot find symbol
symbol : method lookup()
location: @interface javax.annotation.Resource
[INFO] 1 error

Baffled, I checked the class file with javap:

javap -classpath
/Users/ljnelson/.m2/repository/org/glassfish/main/javaee-api/javax.annotation/3.1.2/javax.annotation-3.1.2.jar
javax.annotation.Resource
Compiled from "Resource.java"
public interface javax.annotation.Resource extends
java.lang.annotation.Annotation{
    public abstract java.lang.String name();
    public abstract java.lang.Class type();
    public abstract javax.annotation.Resource$AuthenticationType
authenticationType();
    public abstract boolean shareable();
    public abstract java.lang.String mappedName();
    public abstract java.lang.String description();
}

There is no lookup() attribute in there. Should there be?

Best,
Laird

-- 
http://about.me/lairdnelson