3 Replies Latest reply on Mar 23, 2015 10:58 AM by rubyjb

    JBOSS EAP 6.3.0: Database Connection pool through LDAP throws exception at server startup when "prefill" option  is set to true

    rubyjb Newbie

      Hello,

       

      We have our JBOSS EAP 6.3.0 server set as a managed domain. We are setting up the connection pool to Oracle database through LDAP using an URL as follows:

      jdbc:oracle:thin:@ldap://<ldap server>:<ldap port>/<oracle db name>,cn=OracleContext,dc=xx,dc=yy,dc=com

       

      The pool is setup with "prefill" option set to true.

       

      Our pool configuration in domain.xml looks like below -

      
      <datasource jta="false" jndi-name="java:jboss/test/jdbc/testdb" pool-name="testJDBCPool" enabled="true" use-ccm="false">
              <connection-url>jdbc:oracle:thin:@ldap://<ldap server>:<ldap port>/<oracle db name>,cn=OracleContext,dc=xx,dc=yy,dc=com</connection-url>
              <driver-class>oracle.jdbc.OracleDriver</driver-class>
              <driver>ojdbc6</driver>
              <new-connection-sql>select 1 from dual</new-connection-sql>
              <pool>
                  <min-pool-size>1</min-pool-size>
                  <max-pool-size>50</max-pool-size>
                  <prefill>true</prefill>
                  <use-strict-min>true</use-strict-min>
              </pool>
              <security>
                  <user-name>testusername</user-name>
                  <password>testpassword</password>
              </security>
              <validation>
                  <check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
                  <validate-on-match>true</validate-on-match>
                  <background-validation>false</background-validation>
              </validation>
              <timeout>
                  <set-tx-query-timeout>false</set-tx-query-timeout>
                  <blocking-timeout-millis>0</blocking-timeout-millis>
                  <idle-timeout-minutes>15</idle-timeout-minutes>
                  <query-timeout>0</query-timeout>
                  <use-try-lock>0</use-try-lock>
                  <allocation-retry>5</allocation-retry>
                  <allocation-retry-wait-millis>1000</allocation-retry-wait-millis>
              </timeout>
              <statement>
                  <prepared-statement-cache-size>10</prepared-statement-cache-size>
                  <share-prepared-statements>false</share-prepared-statements>
              </statement>
          </datasource>
          <drivers>
              <driver name="h2" module="com.h2database.h2">
                  <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
              </driver>
              <driver name="ojdbc6" module="com.oracle.db">
                  <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
              </driver>
          </drivers>
      </datasources>
      
      

       

      When the server starts, we are getting following exception -

       

      2015-03-09 13:46:16,120 WARN  [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (JCA PoolFiller) IJ000610: Unable to fill pool: javax.resource.ResourceException: Could not create connection

          at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:324)

             at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:281)

             at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.createConnectionEventListener(SemaphoreArrayListManagedConnectionPool.java:842) [ironjacamar-core-impl-1.0.26.Final-redhat-1.jar:1.0.26.Final-redhat-1]

             at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.fillToMin(SemaphoreArrayListManagedConnectionPool.java:783) [ironjacamar-core-impl-1.0.26.Final-redhat-1.jar:1.0.26.Final-redhat-1]

             at org.jboss.jca.core.connectionmanager.pool.mcp.PoolFiller.run(PoolFiller.java:97) [ironjacamar-core-impl-1.0.26.Final-redhat-1.jar:1.0.26.Final-redhat-1]

             at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_71]

        Caused by: java.sql.SQLRecoverableException: IO Error: JNDI Package failure javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory com.sun.jndi.ldap.LdapCtxFactory from classloader ModuleClassLoader for Module "org.jboss.ironjacamar.impl:main" from local module loader @1a46db0d (finder: local module finder @21d73ff5 (roots: /opt/app/workload/app/jboss630/jbdomain/modules,/opt/app/workload/app/jboss630/jbdomain/modules/system/layers/base)) [Root exception is javax.naming.CommunicationException: odmsvr.sbc.com:3060 [Root exception is java.net.ConnectException: Connection timed out]]

             at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:475)

             at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:552)

             at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:253)

             at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)

             at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:526)

             at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:296)

             ... 5 more

        Caused by: oracle.net.ns.NetException: JNDI Package failure javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory com.sun.jndi.ldap.LdapCtxFactory from classloader ModuleClassLoader for Module "org.jboss.ironjacamar.impl:main" from local module loader @1a46db0d (finder: local module finder @21d73ff5 (roots: /opt/app/workload/app/jboss630/jbdomain/modules,/opt/app/workload/app/jboss630/jbdomain/modules/system/layers/base)) [Root exception is javax.naming.CommunicationException: odmsvr.sbc.com:3060 [Root exception is java.net.ConnectException: Connection timed out]]

             at oracle.net.jndi.JndiAttrs.<init>(JndiAttrs.java:161)

             at oracle.net.resolver.AddrResolution.<init>(AddrResolution.java:193)

             at oracle.net.ns.NSProtocol.connect(NSProtocol.java:219)

             at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1126)

             at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:337)

             ... 10 more

       

       

       

      However, if the "prefill" is set to false OR if the connection to OracleDB is direct (i.e., not through the LDAP), then the pool starts up fine.

       

      After digging for some time, I came up with a fix as follows -

       

      In module.xml in <EAP_HOME>/modules/system/layers/base/org/jboss/ironjacamar/impl/main, I added the following dependency (highlighted) -

       

      <dependencies>

              <!-- javax.security.auth.callback -->

              <module name="sun.jdk"/>

              <module name="javax.api"/>

              <module name="javax.resource.api"/>

              <module name="javax.security.auth.message.api"/>

       

       

      With the above dependency in place, the server starts up fine and the pool is correctly filled up with the "prefill" option.

       

      So here are my questions -

       

      1. Has anyone faced the same problem with the pool with LDAP and prefill together in the mix or is there something wrong with my configuration?
      2. The fix that I did, is this correct? It works, but want to know whether it can cause issues anywhere else. This question is really for JBOSS experts to validate if the fix is correct or whether they have any better solution.

       

      This is my first post to this forum, so apologize if the above info is not adequate.

       

      Thank you.