@Resource(lookup = "java:module/env/rate")Compile the classes:
private String rate;
javac -cp "$GLASSFISH_HOME/modules/*" *Bean.javaIn GlassFish, all JavaEE classes are in various jars under $GLASSFISH_HOME/modules and its subdirectories. It failed because version 1.0 of javax.annotation.Resource class (and other javax.annotation.* classes) are included in Java SE 6. The use of lookup attribute requires version 1.1 of Common Annotation jar, which is included in JavaEE 6.
EmailBean.java:18: cannot find symbol
symbol : method lookup()
location: @interface javax.annotation.Resource
@Resource(lookup = "java:module/env/rate")
^
1 error
To fix it, simply add a -Djava.endorsed.dirs sysprop to override those classes in Java SE 6:
javac -cp "$GLASSFISH_HOME/modules/*" -Djava.endorsed.dirs=$GLASSFISH_HOME/modules/endorsed *Bean.javaIn Eclipse IDE, you just need to put $GLASSFISH_HOME/modules/endorsed/javax.annotation.jar before JRE System Library when configuring Java Build Path.
This should also work with any compliant appserver, though actual jar name and location may vary. The same -Djava.endorsed.dirs sysprop should also be used when running the app.