13 Replies Latest reply on May 8, 2009 3:44 AM by khizz

    problem w/ OracleValidConnectionChecker

    dabramov

      Using:
      JBoss 3.2.6
      Java 1.4.2_05-b04
      Oracle: 9.2.0.1.0
      Oracle driver: 9.0.2.0.0

      I'm trying to use the OracleValidConnectionChecker, but get the exception below when a connection is requested.

      From the error and taking a look a the OracleValidConnectionChecker, it looks like Connection being passed in, isnt' really an Oracle connection. Ideas?

      My datasource config looks like:

      <?xml version="1.0" encoding="UTF-8"?>
      <!-- Data Source for the Insight DB -->
      <datasources>
       <no-tx-datasource>
       <jndi-name>SonusInsightDS</jndi-name>
       <connection-url>jdbc:oracle:thin:@10.6.20.110:1521:DADB</connection-url>
       <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
       <user-name>dbimpl</user-name>
       <password>dbimpl</password>
       <min-pool-size>1</min-pool-size>
       <max-pool-size>2</max-pool-size>
       <idle-timeout-minutes>240</idle-timeout-minutes>
       <!-- Warn when statements and result sets are returned to the connection pool and are not closed -->
       <!-- track-statements>true</track-statements -->
       <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>
       </no-tx-datasource>
      </datasources>



      2005-07-05 16:14:55,185 WARN [org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker] Unexpected error in pingDatabase

      java.lang.IllegalArgumentException: object is not an instance of declaring class

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

      at java.lang.reflect.Method.invoke(Unknown Source)

      at org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker.isValidConnection(OracleValidConnectionChecker.java:51)

      at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnectionFactory.isValidConnection(BaseWrapperManagedConnectionFactory.java:458)

      at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.checkValid(BaseWrapperManagedConnection.java:284)

      at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.matchManagedConnections(LocalManagedConnectionFactory.java:190)

      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:166)

      at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:534)

      at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:444)

      at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:429)

      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:496)

      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:887)

      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:102)
      ...


        • 1. Re: problem w/ OracleValidConnectionChecker
          dabramov

          A bit more info - I added some debug to the OracleValidConnectionChecker. It appears that the Connection that is getting passed to the isValidConnection(Connection c) method is not, in fact, an oracle.jdbc.driver.OracleConnection but rather a JBoss proxy of some kind.

          The top of the isValidConnection method does:

          log.info( "checking valid connection: " + c );
           log.info( "connection is: " + c.getClass().getName() );
           log.info( "ping method: " + ping );
           log.info( "ping method declaring class: " + ping.getDeclaringClass().getName() );


          2005-07-06 14:55:00,444 INFO [MyOracleValidConnectionChecker] checking valid connection: oracle.jdbc.driver.OracleConnection@aee320

          2005-07-06 14:55:00,444 INFO [MyOracleValidConnectionChecker] connection is: $Proxy47


          2005-07-06 14:55:00,445 INFO [MyOracleValidConnectionChecker] ping method: public int oracle.jdbc.driver.OracleConnection.pingDatabase(int) throws java.sql.SQLException

          2005-07-06 14:55:00,446 INFO [MyOracleValidConnectionChecker] ping method declaring class: oracle.jdbc.driver.OracleConnection


          • 2. Re: problem w/ OracleValidConnectionChecker
            alchemista

            I'm getting the same problem, any luck in fixing this without modifying source code?

            • 3. Re: problem w/ OracleValidConnectionChecker
              alchemista

              Here's my stacktrace:

              19:11:01,056 WARN [OracleValidConnectionChecker] Unexpected error in pingDatabase
              java.lang.IllegalArgumentException: object is not an instance of declaring class

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
              java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
              sorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:324)
              at org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker.i
              sValidConnection(OracleValidConnectionChecker.java:54)
              at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnectionFactory.i
              sValidConnection(BaseWrapperManagedConnectionFactory.java:377)
              at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.checkVal
              id(BaseWrapperManagedConnection.java:212)
              at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.m
              atchManagedConnections(LocalManagedConnectionFactory.java:186)
              at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.ge
              tConnection(InternalManagedConnectionPool.java:167)
              at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BaseP
              ool.getConnection(JBossManagedConnectionPool.java:529)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManage
              dConnection(BaseConnectionManager2.java:410)
              at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedCo
              nnection(TxConnectionManager.java:342)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateC
              onnection(BaseConnectionManager2.java:462)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2$Connectio
              nManagerProxy.allocateConnection(BaseConnectionManager2.java:894)
              at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(Wrapp
              erDataSource.java:73)



              Here's my ds.xml to show it's configured correctly (this is working fine with JBoss 3.2.5, I'm now trying to move up to 4.0.2 or 4.0.3 both are giving this error):


              <local-tx-datasource>
              <jndi-name>jdbc/MyDS</jndi-name>
              <connection-url>jdbc:oracle:thin:APP/APP@//mybox:1521/MYDB</connection-url>
              <driver-class>oracle.jdbc.OracleDriver</driver-class>
              <min-pool-size>20</min-pool-size>
              <max-pool-size>400</max-pool-size>

              <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
              <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>

              <!-- Checks the Oracle error codes and messages for fatal errors -->
              <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>

              <!-- Make a large statement cache size for increased performance -->
              <prepared-statement-cache-size>100</prepared-statement-cache-size>

              <!-- Checks for idle connections retrieved from the pool and times them out -->
              <!-- This should be set to the same value as the auto-logout property -->
              <idle-timeout-minutes>30</idle-timeout-minutes>
              </local-tx-datasource>





              I've also noticed now that in some of my queries that then cast results back to oracle.sql.Array type, that is also throwing a ClassCastException.

              • 4. Re: problem w/ OracleValidConnectionChecker
                alchemista

                I opened a bug on this, it seems related to a proxy/wrapper with the JCA that is interfering with some operations:

                http://jira.jboss.com/jira/browse/JBAS-2343

                • 5. Re: problem w/ OracleValidConnectionChecker

                  Your bug report has been deleted since it is not a bug.
                  http://wiki.jboss.org/wiki/Wiki.jsp?page=HelpBugReport

                  I'm not going to tell you what is wrong either because I don't want to encourage
                  you to "ME TOO" or jump the help queue by posting bug reports to get attention.

                  • 6. Re: problem w/ OracleValidConnectionChecker

                    Rhetorical question: Why do think this original question was ignored by me if I thought there was a bug lurking here?

                    • 7. Re: problem w/ OracleValidConnectionChecker

                      Now the "don't abuse the procedure to get attention" is over. :-)

                      For future reference,
                      (in the unlikely event that somebody finds this issue rather than the 1000+
                      similar stupid questions)
                      the problem is like any other ClassCastException.
                      You have two different versions of the class.

                      Rather than looking at the implementation class look at the interface classes
                      (OracleConnection is an interface after all)
                      Class.getInterfaces();
                      and where they are loaded from
                      Class.getClassLoader();
                      Class.getProtectionDomain().getCodeSource()

                      • 8. Re: problem w/ OracleValidConnectionChecker
                        alchemista

                         

                        "adrian@jboss.org" wrote:
                        Now the "don't abuse the procedure to get attention" is over. :-)

                        For future reference,
                        (in the unlikely event that somebody finds this issue rather than the 1000+
                        similar stupid questions)
                        the problem is like any other ClassCastException.
                        You have two different versions of the class.

                        Rather than looking at the implementation class look at the interface classes
                        (OracleConnection is an interface after all)
                        Class.getInterfaces();
                        and where they are loaded from
                        Class.getClassLoader();
                        Class.getProtectionDomain().getCodeSource()


                        Adrian, I posted in the bug report that I already did such things and the class is some sort of wrapper, because when I call the class.getName() it returns the oracle.sql.ARRAY. It works fine in JBoss 3.2.5, but not 4.0.3, same exact configuration on my part, sounds like some sort of bug to me.

                        • 9. Re: problem w/ OracleValidConnectionChecker
                          alchemista

                           

                          "adrian@jboss.org" wrote:
                          Now the "don't abuse the procedure to get attention" is over. :-)

                          For future reference,
                          (in the unlikely event that somebody finds this issue rather than the 1000+
                          similar stupid questions)
                          the problem is like any other ClassCastException.
                          You have two different versions of the class.

                          Rather than looking at the implementation class look at the interface classes
                          (OracleConnection is an interface after all)
                          Class.getInterfaces();
                          and where they are loaded from
                          Class.getClassLoader();
                          Class.getProtectionDomain().getCodeSource()


                          Ok, you were correct (though I wish in a nicer way - "similar stupid questions"). I guess the classloader changed between 3.2.5 and 4.0.3, because in 3.2.5 I had the oracle drivers in both the server/lib and my WEB-INF/lib and it worked fine. However, in 4.0.3, I had to remove the oracle drivers from WEB-INF/lib in order for it to work.

                          Sorry for my "stupid question", but I hope this solution helps someone else out, since obviously other people had such stupid questions as well.

                          • 10. Re: problem w/ OracleValidConnectionChecker
                            mka

                            Certainly helped me out. You'd think such a simple solution would have been presented much earlier by those in the know.

                            • 11. Re: problem w/ OracleValidConnectionChecker
                              nallayeldrab

                              Helped Me! Thanks very much!

                              • 12. Re: problem w/ OracleValidConnectionChecker

                                Thxs this was helpful to me too.

                                • 13. Re: problem w/ OracleValidConnectionChecker
                                  khizz

                                  I have the same problem