2 Replies Latest reply on Jul 25, 2006 8:29 PM by Jonathan Weaver

    ClassCastException when accessing DatabaseMetaData.getTable(

    Jonathan Weaver Newbie

      On 4.0.3SP1, Oracle 10g database, XA transaction datasource, from a remote client, I get hold of the Datasource from the JNDI lookup (yes, I set the <use-java-context>false</use-java-context>).

      After doing a getConnection() on the datasource and a getMetaData() on the connection, I try do use the getTables(...), to get a list of tables and I get a ClassCastException.

      Any ideas on what to do to work around this?

      I made sure the Oracle10g version of the ojdbc14.jar was in the lib on the server and in the classpath for the client. I also have jbossall-client.jar in the classpath of the client.

        • 1. Re: ClassCastException when accessing DatabaseMetaData.getTa
          Oleg Zhurakousky Newbie

          What r u casting it too and can you post your code here?

          Also, see what it is returning by retrieving object as java.lang.Object (which will never throw ClassCastException) and see what it is.


          Object obj = ds.getConnection().getMetaData();
          System.out.println("Object class: " + obj.getClass().getName());


          Oleg Zhurakousky

          • 2. Re: ClassCastException when accessing DatabaseMetaData.getTa
            Jonathan Weaver Newbie

            Thanks for responding.
            The code is as follows where conn is a Connection
            returned from a call to getConnection() on a Datasource from a remote server to my client application using JNDI lookup:

            DatabaseMetaData dbMeta = conn.getMetaData();
            try {
            tableRes = dbMeta.getTables(null, null, null, types);
            } catch (Exception e) {

            The types variable is an array of strings with values TABLE, VIEW, SYNONYM.

            As you can see I do not do any casting. It is the
            getTables(...) method that throws the exception.

            If you would like I can expose the datasource file here.

            It appears to me there is a problem with the proxy used to wrap the DatabaseMetaData and it is a problem when the datasource is to an Oracle database using the thin client driver.