title: How to filter (substitute) env-entry values in ebj-jar.xml for unit tests with embedded enterprise bean container (GlassFish)?
body: <p>I need several profiles for deployment. In the Maven POM I have defined a profile "dev" and a property "theHost" (as localhost):</p>
  
  <pre><code>&lt;profiles&gt;
    &lt;profile&gt;
      &lt;id&gt;dev&lt;/id&gt;
      &lt;activation&gt;
        &lt;activeByDefault&gt;true&lt;/activeByDefault&gt; &lt;!-- use dev profile by default --&gt;
      &lt;/activation&gt;
      &lt;build&gt;
      &lt;/build&gt;
      &lt;properties&gt;
        &lt;theHost&gt;localhost&lt;/theHost&gt;
      &lt;/properties&gt;
    &lt;/profile&gt;
  ...
  </code></pre>
  
  <p>I have activated <code>filterDeploymentDescriptor</code> on the maven-ejb-plugin in order to tell it to filter (substitute) values in ejb-jar.xml:</p>
  
  <pre><code>&lt;plugins&gt;
    &lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-ejb-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.3&lt;/version&gt;
      &lt;configuration&gt;
        &lt;ejbVersion&gt;3.1&lt;/ejbVersion&gt;
  --&gt;   &lt;filterDeploymentDescriptor&gt;true&lt;/filterDeploymentDescriptor&gt;
      &lt;/configuration&gt;
  &lt;/plugin
  </code></pre>
  
  <p>Finally, in ejb-jar.xml I refer to <code>${theHost}</code> to obtain the desired profile-specific  value for the @Resource attribute "host":</p>
  
  <pre><code>&lt;session&gt;
    &lt;ejb-name&gt;MongoDao&lt;/ejb-name&gt;
    &lt;ejb-class&gt;com.coolcorp.MongoDao&lt;/ejb-class&gt;
    &lt;session-type&gt;Stateless&lt;/session-type&gt;
    &lt;env-entry&gt;
      &lt;env-entry-name&gt;host&lt;/env-entry-name&gt;
      &lt;env-entry-type&gt;java.lang.String&lt;/env-entry-type&gt;
      &lt;env-entry-value&gt;${theHost}&lt;/env-entry-value&gt;
    &lt;/env-entry&gt;
  ...
  </code></pre>
  
  <p>This all works great with a regular Maven build. But when I run an EJB unit test using the Embedded Enterprise Bean Container of GlassFish [EJBContainer.createEJBContainer()], the maven-ejb-plugin seems to ignore filterDeploymentDescriptor=true. The EJB sees "${theHost}" instead of "localhost" although I run maven with the same "dev" profile.</p>
  
  <pre><code>mvn.bat -Pdev test
  </code></pre>
  
  <p>Does anybody have an idea why the substitution does not work when running a unit test? Is there something more I have to define especially for the unit test so that filtering of ejb-jar.xml occurs? Or a better approach to unit testing EJBs if different profiles exist?</p>