 <p>Ideally, you would be able to specify an external "binding" for the env-entry. I know that's possible to do with WebSphere Application Server (via <a href="http://pic.dhe.ibm.com/infocenter/wasinfo/v8r5/topic/com.ibm.websphere.base.doc/ae/rejb_emconproperties.html" rel="nofollow">EnvEntry.Value properties</a>), but I don't know if it's possible with Glassfish.</p> <p>As a workaround, you could declare the env-entry for injection, and then check in PostConstruct whether any value was injected by the container (i.e., don't specify env-entry-value until you're deploying into the server). If you're using JNDI only, you can do the same thing with try/catch(NameNotFoundException).</p> <pre><code>@Resource(name="host") private String host; @PostConstruct public void postConstruct() { if (host == null) { // Not configured at deployment time. host = System.getProperty("test.host"); } } </code></pre>