Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-2473

Remote side ClassCastExceptions as a result of WrapperDataSourceService using "getInterfaces()" to create Proxies.

    XMLWordPrintable

Details

    Description

      The methods, createStatementProxy and createResultSetProxy in WrapperDataSourceService use Object.getClass().getInterfaces() to gather interface information in order to create proxies to the database driver Statement and ResultSet objects. However, if the underlying driver implementation objects inherit their interfaces from a superclass, "getInterfaces()" will not return those interfaces. (Derby Embedded driver does this for ResultSet) This causes a ClassCastException on the remote side.

      Other methods like createDatabaseMetaData just set the java.sql interface explicitly when creating the proxy. (I don't know if there was a reason not to do this in these two methods).

      public interface MyInterface{
      public void interfaceMethod();
      }

      public abstract class MyObjectA implements MyInterface{
      public void interfaceMethod()

      { //Implement interface }

      }

      public class MyObjectB extends MyObjectA{
      public void interfaceMethod()

      { //Overridden implementation }

      }

      public class Tester{
      public static void main(String[] args)

      { MyObjectB b = new MyObjectB(); Class[] ifaces = b.getClass().getInterfaces(); //<----------- This will not contain MyInterface }

      }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jbarkanic J Barkanic (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: