title: Spring 3 JNDI look up in glassfish3
body: <p>I want to look up some properties from JNDI configured in glassfish v3 server. I want to do it using spring. Here is my spring configuration:</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:aop="http://www.springframework.org/schema/aop"
         xmlns:jee="http://www.springframework.org/schema/jee"
         xmlns:jaxws="http://cxf.apache.org/jaxws"
         xsi:schemaLocation="http://www.springframework.org/schema/beans
                             http://www.springframework.org/schema/beans/spring-beans.xsd
                             http://www.springframework.org/schema/aop
                             http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
                             http://www.springframework.org/schema/beans
                             http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                             http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
                             http://www.springframework.org/schema/jee
                             http://www.springframework.org/schema/jee/spring-jee-3.0.xsd"&gt;
  
      &lt;import resource="classpath:META-INF/cxf/cxf.xml"/&gt;
      &lt;import resource="classpath:META-INF/cxf/cxf-servlet.xml"/&gt;
  
      &lt;!--
          JNDI look ups.
       !--&gt;
      &lt;jee:jndi-lookup id="properties"
                       jndi-name="java:comp/env/jndi/ws_properties"
                       expected-type="java.util.Properties"/&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>I have mapped <code>jndi/ws_properties</code> in sun-web.xml and web.xml files. Problem is that this lookup always gives me null properties. But if I do it in java code:</p>
  
  <pre><code>    try {
          InitialContext context = new InitialContext();
          properties = (Properties) context.lookup("jndi/ws_properties");
      } catch (NamingException e) {
          LOGGER.error("", e);
      }
  </code></pre>
  
  <p>It is ok. I see my properties keys and values.</p>
  
  <p>Could somebody tell me where is the problem here?</p>