title: JNDI lookup on Glassfish 4.1.1 custom resources
body: <p>I am trying to use JNDI custom resources to store data directly in my server (Glassfish) but it is apparently not working.</p>
  
  <p>I define my JNDI as on the image below</p>
  
  <p><a href="https://i.stack.imgur.com/7szT2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7szT2.png" alt="enter image description here"></a></p>
  
  <p>which corresponds to the following description in my domain.xml.</p>
  
  <pre><code>&lt;custom-resource factory-class="org.glassfish.resources.custom.factory.PrimitivesAndStringFactory" res-type="java.lang.String" jndi-name="projectStage"&gt;
        &lt;property name="value" value="UnitTest"&gt;&lt;/property&gt;
  &lt;/custom-resource&gt;
  </code></pre>
  
  <p>And then, i am trying to get this value in one of my managed bean.</p>
  
  <pre><code>Context c = new InitialContext();
  c.lookup("projectStage");
  </code></pre>
  
  <p>But... <code>javax.naming.NamingException: Lookup failed for 'projectStage'</code> is the only thing i get from it.</p>
  
  <p>If anyone has an idea for me, i will be thankful !</p>