title: simple string value by JNDI in Java
body: <p>How can i set simple string value in configuration of tomcat and then read in java application?</p>
  
  <p>context.xml</p>
  
  <pre><code>&lt;ResourceLink name="global/test" global="testing" type="java.lang.String" /&gt;
  </code></pre>
  
  <p>server.xml</p>
  
  <pre><code>&lt;Enviroment name="testing" value="myUser" type="java.lang.String"/&gt;
  </code></pre>
  
  <p>web.xml in application</p>
  
  <pre><code>&lt;resource-env-ref&gt;
      &lt;resource-env-ref-name&gt;global/test&lt;/resource-env-ref-name&gt;
      &lt;resource-env-ref-type&gt;java.lang.String&lt;/resource-env-ref-type&gt;
  &lt;/resource-env-ref&gt;
  </code></pre>
  
  <p>in my java application</p>
  
  <pre><code>public String getValue(){
      return new JndiDataSourceLookup().getDataSource("global/test").toString();
  }
  </code></pre>
  
  <p>When i Run tomcat, i see these errors...</p>
  
  <pre><code>org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'global/test'; nested exception is javax.naming.NameNotFoundException: Name [global/test] is not bound in this Context. Unable to find [global].
  javax.naming.NameNotFoundException: Name [global/test] is not bound in this Context. Unable to find [global].
  </code></pre>