This does not work (= null):
@Resource(name = "java:app/AppName") private String appName;
But search with the same name:
appName = (String) new javax.naming.InitialContext().lookup("java:app/AppName");
I found many examples having a search property in @Resource instead of a name. However, I can not find anything about this, I am quite sure that this should be a name, the first is not included in the specification.
FYI, I am using Glassfish 3.1, and I am accessing the appName from the @PostConstruct method in a singleton bean.
source share