0 Replies Latest reply on Apr 3, 2017 5:52 AM by Sanjith Sathinadhan

    $Proxyxxx cannot be cast to java.sql.ResultSet

    Sanjith Sathinadhan Newbie

      I am trying to use jndi datasource of jboss, in an external standalone java program. But when i access any method in DatabaseMetaData which returns ResultSet i get the error

      $Proxyxxx cannot be cast to java.sql.ResultSet

       

      I am using jboss-eap-5.1, JDK 1.6.0_38, oracle linux 6.1.

      Java program has the following lib in its class path

      jboss-client.jar

      jboss-common-core.jar

      jboss-integration.jar

      jboss-javaee.jar

      jboss-logging-spi.jar

      jboss-remoting.jar

      jboss-security-spi.jar

      jboss-serialization.jar

      jbosscx-client.jar

      jbosssx-client.jar

      jnp-client.jar

      jboss-common-jdbc-wrapper.jar

       

      Java code snippet

      final Hashtable env = new Hashtable();

      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

      env.put(Context.PROVIDER_URL, "jnp://localhost:1999");

      final Context ctx = new InitialContext(env);

      final Object lobj = ctx.lookup("MyJNDI");

      final DataSource source = (DataSource) lobj;

      final Connection connection = source.getConnection(); //success

      final DatabaseMetaData data = connection.getMetaData();

      final ResultSet resultSet = data.getSchemas(); //error in this line

       

      I have exposed the jndi setting in my *-ds.xml file by adding the jndi name to global context (as per Exposing/Accessing JBoss JNDI Objects/Datasources From an External JVM | engfer(s) ).

      How can i solve this issue?

       

      Note: Inside the webapp if i print datasource class name i get org.jboss.resource.adapter.jdbc.WrapperDataSource. But in java program i get java.lang.Proxy.