Hello all.
I'm having trouble using environment entries to configure an
application on deployment in Glassfish.
web.xml:
<web-app ...>
<env-entry>
<env-entry-name>config/user</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
</web-app>
ServiceProducer.java:
@ApplicationScoped
public class ServiceProducer {
@Produces
@Default
public Service get() {
return new ServiceImpl(user);
}
private String user;
@Resource(name = "java:comp/env/config/user")
public void setUser(String user) {
this.user = user;
}
}
With "GlassFish Server Open Source Edition 4.0 (build 89)" the
ServiceProducer.get() is called before setUser() is called.
I'm at a loss here: How can I configure the application?
I have added a config/user JNDI Custom Resource:
Resource Type: java.lang.String
Factory Class:
org.glassfish.resources.custom.factory.PrimitivesAndStringFactory
Status : Enabled (checked)
Properties:
name = "value", value = "ConfiguredUserName"
Please advise! I'm getting seriously frustrated with this.