<?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>Tomcat connection pool error in DXP</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=90965371" />
  <subtitle>Tomcat connection pool error in DXP</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=90965371</id>
  <updated>2026-04-04T22:34:44Z</updated>
  <dc:date>2026-04-04T22:34:44Z</dc:date>
  <entry>
    <title>RE: Tomcat connection pool error in DXP</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119706449" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119706449</id>
    <updated>2020-08-05T02:36:59Z</updated>
    <published>2020-08-05T02:36:59Z</published>
    <summary type="html">The JNDI context for the app server is not exposed into the OSGi container. In order to get to it you have to use the Portal&amp;#39;s class loader, something the JndiObjectFactoryBean has no idea how to do.&lt;br /&gt;&lt;br /&gt;You have to use your own implementation of that class that knows how to temporarily switch to the portal class loader when doing the JNDI lookup and restoring on return.</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2020-08-05T02:36:59Z</dc:date>
  </entry>
  <entry>
    <title>RE: Tomcat connection pool error in DXP</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119702232" />
    <author>
      <name>Dipak Ahuja</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119702232</id>
    <updated>2020-08-04T12:35:16Z</updated>
    <published>2020-08-04T12:35:16Z</published>
    <summary type="html">Yes Olaf, it works fine for me with Liferay 6.1, whereas the same issue I observed with Liferay 7.3 and tomcat 9. Please find below the configuration for server.xml and portlet-application-context.xml respectively.&lt;br /&gt;&lt;br /&gt;server.xml&lt;br /&gt;&lt;br /&gt;&amp;lt;Resource name=&amp;#34;jdbc/LiferayPool&amp;#34;&lt;br /&gt;              global=&amp;#34;jdbc/LiferayPool&amp;#34;&lt;br /&gt;              factory=&amp;#34;org.apache.tomcat.jdbc.pool.DataSourceFactory&amp;#34;&lt;br /&gt;              auth=&amp;#34;Container&amp;#34;&lt;br /&gt;              type=&amp;#34;javax.sql.DataSource&amp;#34;             &lt;br /&gt;              username=&amp;#34;root&amp;#34;&lt;br /&gt;              password=&amp;#34;root&amp;#34;&lt;br /&gt;              driverClassName=&amp;#34;com.mysql.cj.jdbc.Driver&amp;#34;&lt;br /&gt;              description=&amp;#34;Liferay database.&amp;#34;&lt;br /&gt;              url=&amp;#34;jdbc:mysql://localhost:3305/lportal731?autoReconnect=true&amp;#34;&lt;br /&gt;              testWhileIdle=&amp;#34;true&amp;#34;&lt;br /&gt;              testOnBorrow=&amp;#34;true&amp;#34;/&amp;gt;&lt;br /&gt;&lt;br /&gt;context.xml   &lt;br /&gt;&lt;br /&gt; &amp;lt;ResourceLink name=&amp;#34;jdbc/LiferayPool&amp;#34; global=&amp;#34;jdbc/LiferayPool&amp;#34; type=&amp;#34;javax.sql.DataSource&amp;#34;/&amp;gt;&lt;br /&gt;portlet-application-context.xml&lt;br /&gt;&amp;lt;bean id=&amp;#34;jndiDataSource&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/LiferayPool&amp;#34;/&amp;gt;&lt;br /&gt;    &amp;lt;/bean&amp;gt;&lt;br /&gt;    &amp;lt;bean id=&amp;#34;hibernateJpaVendorAdapter&amp;#34;&lt;br /&gt;        class=&amp;#34;org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter&amp;#34; /&amp;gt;&lt;br /&gt;    &amp;lt;bean id=&amp;#34;entityManagerFactory&amp;#34;&lt;br /&gt;        class=&amp;#34;org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean&amp;#34;&amp;gt;&lt;br /&gt;        &amp;lt;property name=&amp;#34;dataSource&amp;#34; ref=&amp;#34;jndiDataSource&amp;#34; /&amp;gt;&lt;br /&gt;        &amp;lt;property name=&amp;#34;jpaVendorAdapter&amp;#34; ref=&amp;#34;hibernateJpaVendorAdapter&amp;#34; /&amp;gt;&lt;br /&gt;        &amp;lt;property name=&amp;#34;packagesToScan&amp;#34; value=&amp;#34;com.nividous.rpa.domain&amp;#34; /&amp;gt;&lt;br /&gt;        &amp;lt;property name=&amp;#34;jpaProperties&amp;#34;&amp;gt;&lt;br /&gt;            &amp;lt;props&amp;gt;&lt;br /&gt;                &amp;lt;prop key=&amp;#34;hibernate.dialect&amp;#34;&amp;gt;org.hibernate.dialect.MySQL8Dialect&amp;lt;/prop&amp;gt;&lt;br /&gt;                &amp;lt;prop key=&amp;#34;hibernate.hbm2ddl.auto&amp;#34;&amp;gt;update&amp;lt;/prop&amp;gt;                &amp;lt;prop key=&amp;#34;hibernate.show_sql&amp;#34;&amp;gt;true&amp;lt;/prop&amp;gt;&lt;br /&gt;                &amp;lt;prop key=&amp;#34;hibernate.format_sql&amp;#34;&amp;gt;false&amp;lt;/prop&amp;gt;&lt;br /&gt;            &amp;lt;/props&amp;gt;&lt;br /&gt;        &amp;lt;/property&amp;gt;&lt;br /&gt;    &amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;Thanks in advance.&lt;br /&gt;&lt;br /&gt;Cheers,&lt;br /&gt;Dipak</summary>
    <dc:creator>Dipak Ahuja</dc:creator>
    <dc:date>2020-08-04T12:35:16Z</dc:date>
  </entry>
  <entry>
    <title>RE: Tomcat connection pool error in DXP</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=100731312" />
    <author>
      <name>Olaf Kock</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=100731312</id>
    <updated>2017-12-13T10:43:27Z</updated>
    <published>2017-12-13T10:43:27Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;div class="quote-title"&gt;Jatinderveer Singh:&lt;/div&gt;&lt;blockquote&gt;&lt;pre&gt;&lt;code&gt;
java.lang.ClassCastException: org.apache.naming.ResourceLinkRef cannot be cast to javax.sql.DataSource 
        at com.test.HbaseUtil.openConnection(HbaseUtil.java:55) 
        at com.test.DAOImpl.getDetails(DAOImpl.java:112) 
        at com.test.HomeMBean.getDetails(HomeMBean.java:341) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
&lt;/code&gt;&lt;/pre&gt; &lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;&lt;br&gt;While the original question is somewhat old, after two more having stated "the same" problem, I'd like to ask for more information - everybody who posted here:&lt;br&gt;&lt;br&gt;&lt;ul&gt;&lt;li&gt;Are you sure you have the same problem? With code from the com.test package? At least this is not part of Liferay&lt;/li&gt;&lt;li&gt;Your configuration might have been worked with Liferay 6.2, but that might also have been on a different tomcat version. You don't give any hint about the configuration you're using, no steps to reproduce&lt;/li&gt;&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Olaf Kock</dc:creator>
    <dc:date>2017-12-13T10:43:27Z</dc:date>
  </entry>
  <entry>
    <title>RE: Tomcat connection pool error in DXP</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=100665850" />
    <author>
      <name>Lavanya Chimata</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=100665850</id>
    <updated>2017-12-12T16:34:20Z</updated>
    <published>2017-12-12T16:34:20Z</published>
    <summary type="html">We are experiencing similar issue. Is it resolved for you?</summary>
    <dc:creator>Lavanya Chimata</dc:creator>
    <dc:date>2017-12-12T16:34:20Z</dc:date>
  </entry>
  <entry>
    <title>RE: Tomcat connection pool error in DXP</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=91542126" />
    <author>
      <name>Kristina la pietra</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=91542126</id>
    <updated>2017-07-07T10:47:24Z</updated>
    <published>2017-07-07T10:47:24Z</published>
    <summary type="html">Hi,&lt;br /&gt;I have the same problem with liferay 7 ga3 and tomcat8 . Also for me the same configuration correctaly work in liferay 6.2. &lt;br /&gt;I have the same problem both with hibernate configuration and with Spring. With Hibernate I tested the connection using jdbc and it works.</summary>
    <dc:creator>Kristina la pietra</dc:creator>
    <dc:date>2017-07-07T10:47:24Z</dc:date>
  </entry>
  <entry>
    <title>Tomcat connection pool error in DXP</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=90965370" />
    <author>
      <name>Jatinderveer Singh</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=90965370</id>
    <updated>2017-06-22T07:52:30Z</updated>
    <published>2017-06-22T07:52:30Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;I have a JNDI connection pool defined at Tomcat level . When i start the server the connection pool is set up and no error is thrown but when i try to retrieve the same pool from my portlet using a simple java class i get the following error&lt;br&gt; &lt;pre&gt;&lt;code&gt;
java.lang.ClassCastException: org.apache.naming.ResourceLinkRef cannot be cast to javax.sql.DataSource 
        at com.test.HbaseUtil.openConnection(HbaseUtil.java:55) 
        at com.test.DAOImpl.getDetails(DAOImpl.java:112) 
        at com.test.HomeMBean.getDetails(HomeMBean.java:341) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
&lt;/code&gt;&lt;/pre&gt; &lt;br&gt;&lt;br&gt;Is there something in particular that i need to take care of when my portlet is deployed in OSGI framework to get this working. The same code was working in Liferay 6.2 and is working in vanilla Tomcat 8.&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Jatinderveer Singh</dc:creator>
    <dc:date>2017-06-22T07:52:30Z</dc:date>
  </entry>
</feed>
