problem while returning resultset


EJB programming & troubleshooting: problem while returning resultset

  1. problem while returning resultset (2 messages)


    I am working on a stateless session bean which has two methods.The first method will take in a query string and execute it and returns the number of rows inserted,updated and deleted.This works fine.

    The second method again recieves a query string and returns a resultset.Here is the code,

    public java.sql.ResultSet read(String query) throws RemoteException,SQLException
    java.sql.Connection conn=null;
    java.sql.Statement stmt=null;
    java.sql.ResultSet rs=null;
    catch(SQLException e)
    catch(Exception se)
    System.out.println("Error"+ se);
    System.out.println("Before Resultset" );
    return (java.sql.ResultSet)rs;


    When i print the resultset it gives me all the values for the query on the server i use weblogic 5.1 application server.

    The problem is whenever a client accesses this method it throws a ClassCastException.The stack trace it prints is

    java.lang.ClassCastException: weblogic.jdbc20.rmi.internal.ResultSetStub

    java.lang.ClassCastException: weblogic.jdbc20.rmi.internal.ResultSetStub

    at weblogic.jdbc20.rmi.SerialResultSet.readObject(

    at weblogic.common.internal.WLObjectInputStreamBase.readPublicSerializable(

    at weblogic.common.internal.WLObjectInputStreamBase.readLeftover(

    at weblogic.common.internal.WLObjectInputStreamBase.readObjectBody(

    at weblogic.common.internal.WLObjectInputStreamBase.readObject(

    at weblogic.common.internal.WLObjectInputStreamBase.readObjectWL(

    at weblogic.rmi.extensions.AbstractInputStream2.readObject(


    at, Compiled Code)

    at hello.go(

    at hello.main(

    The error is on the client side and the server prints the resultset.There is an error while dispatching the resutlset.

    One funny thing,this bean was working fine i modified it and put some SOP's in between and from then it is not working.


  2. problem while returning resultset[ Go to top ]

    Perhaps ResultSet is not serializable, and so cannot
    be sent to the client via RMI. Instead of returning
    a ResultSet, why not place the data into a serializable
    object and return that instead (Tom Valesky's "Enterprise Java Beans" does this with an InventoryItem; talks alittle about Serializable on p. 84).

    No idea why it worked for you before the SOPs.

  3. problem while returning resultset[ Go to top ]

    why dont u use? vector for returning the result to the client as its serializeable.
    i also had classcast exception. the reason for thats was that i had some older versions of that file as well in the same package so it tried to cast it with the older version but the implementation is according to the newer version so try to remove all unnecessary files from ur package