users@glassfish.java.net

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

From: Shalini <shalini.muthukrishnan_at_oracle.com>
Date: Mon, 06 Aug 2012 15:46:01 +0530

Hi Laird,

Could you try adding the following in your pom.xml?

<plugin>
       <artifactid>maven-compiler-plugin</artifactid>
       <configuration>
        <compilerargument>-Djava.endorsed.dirs="${gf.home}/modules/endorsed"</compilerargument>
       </configuration>
      </plugin>

This is to instruct maven to endorse dependencies during compile.

Thanks
Shalini.


On Saturday 04 August 2012 01:57 AM, Laird Nelson wrote:
> 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()
> <http://docs.oracle.com/javaee/6/api/javax/annotation/Resource.html#lookup%28%29>
>
> 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
>