title: Issue JNDI resource initialization - DB connection @"DB2 on Cloud - BLUEMIX
body: <p>We are unable to make DB2 database connection from Java application deployed on &quot;Liberty on Java&quot; using JNDI resource at Bluemix.</p>
  <p>It is not able to initialize the resource.</p>
  <p>My server.xml file is</p>
  <pre><code> &quot;&lt;dataSource id=&quot;eVotingDataSource&quot; jdbcDriverRef=&quot;db2-driver&quot; jndiName=&quot;jdbc/DatabaseName&quot; type=&quot;javax.sql.DataSource&quot;&gt;
      &lt;properties.db2.jcc id=&quot;eVotingDataSource-props&quot; databaseName=&quot;*******&quot; user=&quot;db2inst1&quot; password=&quot;******&quot; portNumber=&quot;50001&quot; serverName=&quot;********&quot; sslConnection=&quot;true&quot;/&gt;
  &lt;/dataSource&gt;
  &lt;jdbcDriver id=&quot;db2-driver&quot; libraryRef=&quot;db2-library&quot;/&gt;
  &lt;library id=&quot;db2-library&quot;&gt;
      &lt;fileset id=&quot;db2-fileset&quot; dir=&quot;${server.config.dir}/lib&quot; includes=&quot;db2jcc4.jar db2jcc_license_cu.jar&quot;/&gt;
  &lt;/library&gt;
  </code></pre>
  <p>Web.xml file</p>
  <pre><code>&lt;resource-ref&gt;
  &lt;description&gt;DB Connection&lt;/description&gt;
  &lt;res-ref-name&gt;jdbc/DatabaseName&lt;/res-ref-name&gt;
  &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
  &lt;res-auth&gt;Container&lt;/res-auth&gt;
  </code></pre>
  
  <p>applicationContext.xml file</p>
  <pre><code>&lt;jee:jndi-lookup id=&quot;eVotingDataSource&quot;
  </code></pre>
  <p>jndi-name=&quot;jdbc/DatabaseName&quot;
  expected-type=&quot;javax.sql.DataSource&quot; /&gt;</p>
  <p>Below is output of messages.log</p>
  <blockquote>
  <p>org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.nl.abnamro.evoting.dao.IssuerDAOImpl.eVotingSessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eVotingSessionFactory' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'eVotingDataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eVotingDataSource': Invocation of init method failed; nested exception is javax.naming.NamingException: CWWKN0008E: An object could not be obtained for name jdbc/DatabaseName.</p>
  <p>Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eVotingDataSource': Invocation of init method failed; nested exception is javax.naming.NamingException: CWWKN0008E: An object could not be obtained for name jdbc/DatabaseName.</p>
  <p>Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eVotingMailSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Intermediate context does not exist: mail/Session</p>
  </blockquote>
  <p>When we load the application we receive the following error:</p>
  <blockquote>
  <p>Error 500: javax.servlet.ServletException: Filter [springSecurityFilterChain]: could not be initialized</p>
  </blockquote>
  <p>Could you please assist?</p>