title: How to set jndiname property value using Spring JndiObjectFactoryBean for tomcat7? My property value here is a file
body: <p>I'm trying to convert a webapplication running in jboss5 to tomcat7. I need to change the JNDI configuration for metadata properties to work in tomcat. The metadata properties are configured in an external property file and the property file has to be loaded during the application startup.</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;bean id="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
      &lt;property name="locations"&gt;
          &lt;list&gt;                
              &lt;bean class="org.springframework.core.io.FileSystemResource"&gt;
                  &lt;constructor-arg&gt;
                      &lt;bean class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
                          &lt;property name="jndiName" value="${CATALINA_HOME}/conf/metadata.properties" /&gt;                           
                      &lt;/bean&gt;
                  &lt;/constructor-arg&gt;
              &lt;/bean&gt;                
         &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>The application should load the jndiName property value but it is not working.
  It throws the following error,</p>
  
  <pre><code>Caused by: javax.naming.NameNotFoundException: Name [${CATALINA_HOME}/conf/metadata.properties] is not bound in this Context. Unable to find [${CATALINA_HOME}].
  </code></pre>
  
  <p>whereas the same configuration had given for jboss. In place of <code>${CATALINA_HOME}</code> it was given <code>"external/config/"</code>. </p>
  
  <p>Can you guys help me out whether am i missing any other configuration for tomcat.</p>
  
  <p>(I have also defined <code>${CATALINA_HOME}</code> environment variable in <code>catalina.sh</code> file and other property files are loaded correctly. Even if i give the absolute path it shows the same error.)</p>
  
  <pre><code>Caused by: javax.naming.NameNotFoundException: Name [root/user1/apache-tomcat-7.0.92/conf/metadata.properties] is not bound in this Context. Unable to find [root].
  </code></pre>