<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Connecting to JNDI Data Sources</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=118032960" />
  <subtitle>Connecting to JNDI Data Sources</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=118032960</id>
  <updated>2026-04-06T11:51:12Z</updated>
  <dc:date>2026-04-06T11:51:12Z</dc:date>
  <entry>
    <title>RE: Connecting to JNDI Data Sources</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118042510" />
    <author>
      <name>Pankaj Kumar</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118042510</id>
    <updated>2019-12-10T16:11:07Z</updated>
    <published>2019-12-10T16:11:07Z</published>
    <summary type="html">Ok..Thanks...I was able to get the Datasource connection through the way we get in J2EE application.&lt;br /&gt;InitialContext ctx = new InitialContext();</summary>
    <dc:creator>Pankaj Kumar</dc:creator>
    <dc:date>2019-12-10T16:11:07Z</dc:date>
  </entry>
  <entry>
    <title>RE: Connecting to JNDI Data Sources</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118041314" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118041314</id>
    <updated>2019-12-10T13:20:49Z</updated>
    <published>2019-12-10T13:20:49Z</published>
    <summary type="html">You can&amp;#39;t use the spring example because it will not properly set the class loader.</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2019-12-10T13:20:49Z</dc:date>
  </entry>
  <entry>
    <title>RE: Connecting to JNDI Data Sources</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118036132" />
    <author>
      <name>Pankaj Kumar</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118036132</id>
    <updated>2019-12-10T05:03:10Z</updated>
    <published>2019-12-10T05:03:10Z</published>
    <summary type="html">Thanks David  for response.&lt;br /&gt;In ext.spring file i have added below property  &amp;lt;bean id=&amp;#34;bean1&amp;#34; class=&amp;#34;org.springframework.jndi.JndiObjectFactoryBean&amp;#34;&amp;gt;&lt;br /&gt;        &amp;lt;property name=&amp;#34;jndiName&amp;#34; value=&amp;#34;java:comp/env/jdbc/db1&amp;#34; /&amp;gt;&lt;br /&gt;         &lt;br /&gt;    &amp;lt;/bean&amp;gt;&lt;br /&gt;    &lt;br /&gt;     &amp;lt;bean id=&amp;#34;customDBDataSource&amp;#34; class=&amp;#34;org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy&amp;#34; lazy-init=&amp;#34;true&amp;#34;&amp;gt;&lt;br /&gt;    &amp;lt;property name=&amp;#34;targetDataSource&amp;#34;&amp;gt;&lt;br /&gt;        &amp;lt;ref bean=&amp;#34;bean1&amp;#34; /&amp;gt;&lt;br /&gt;    &amp;lt;/property&amp;gt;and while starting the module i am getting below error&lt;br /&gt; Invocation of init method failed; nested except&lt;br /&gt;ion is javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.naming.java.javaURLContextFactory [Root exception is java.lan&lt;br /&gt;g.ClassNotFoundException: Unable to load class org.apache.naming.java.javaURLContextFactory]&lt;br /&gt;        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562)</summary>
    <dc:creator>Pankaj Kumar</dc:creator>
    <dc:date>2019-12-10T05:03:10Z</dc:date>
  </entry>
  <entry>
    <title>RE: Connecting to JNDI Data Sources</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118035335" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118035335</id>
    <updated>2019-12-09T21:11:41Z</updated>
    <published>2019-12-09T21:11:41Z</published>
    <summary type="html">The only caveat is that you need to set the class loader to the portal&amp;#39;s class loader before you invoke the JNDI lookup.&lt;br /&gt;&lt;br /&gt;Otherwise the JNDI lookup is exactly the same as you would do it in any other application.</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2019-12-09T21:11:41Z</dc:date>
  </entry>
  <entry>
    <title>Connecting to JNDI Data Sources</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118032959" />
    <author>
      <name>Pankaj Kumar</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118032959</id>
    <updated>2019-12-09T19:08:49Z</updated>
    <published>2019-12-09T19:08:49Z</published>
    <summary type="html">Hi All,&lt;br /&gt;I am using Liferay dxp 7.2.Can any body tell me how we can connect to external database using JNDI Data Sources.&lt;br /&gt;Thanks,Pankaj Semwal</summary>
    <dc:creator>Pankaj Kumar</dc:creator>
    <dc:date>2019-12-09T19:08:49Z</dc:date>
  </entry>
</feed>
