Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    1

    Unhappy Unanswered: Persisting of Java Objects using setObject()/getObject()

    Hi,

    Currently i'm trying to serialize a object into a mySql db using the setObject() and the getObject() methods.

    I'm using Jboss 3.2 with a mysql-ds.xml data source file

    having seperate 2 applications:

    1. AdminReportGen: Calculates results and serializes them to a mysql db
    2. Reports: Displays results by retrieving serialized result objects from the db.

    I have no problems using the setObject() method, it works fine.
    However when i use the getObject() method to retrieve the serialized object, it tells me it cannot find the class. This seems stange to me because it is included in the ear file.

    The setObject methodes looks something like this(simplyfied)
    <code>
    public void insertresult(Object result){

    PreparedStatement st = new PreparedStatement(statement);
    st.setObject(2,reportresult);

    }</code>

    The getObject methodes looks something like this(simplyfied)
    <code>

    public reports[] getreports(){

    rs = st.executeQuery ();
    List list = new ArrayList ();

    while (rs.next ()) {

    Report report = new Report ();
    report.setResult(rs.getObject("reportresult"));
    list.add (report);
    }
    </code>

    this is the error i get from the msql jdbc driver

    java.sql.SQLException: Class not found: java.lang.ClassNotFoundException: Result while reading serialized object
    at com.mysql.jdbc.ResultSet.getObject(ResultSet.java: 1508)
    at com.mysql.jdbc.ResultSet.getObject(ResultSet.java: 1550)

    Anyone who knows a solution? I seem to have run out of options.

    Regards and grtz,

    Idle,

    Last edited by Idle; 05-05-03 at 11:29.

  2. #2
    Join Date
    Aug 2003
    Posts
    1

    Re: Persisting of Java Objects using setObject()/getObject()

    I have the same problem. Did you by any chance get around to solving it?
    Thanks
    Ivy

    Originally posted by Idle
    Hi,

    Currently i'm trying to serialize a object into a mySql db using the setObject() and the getObject() methods.

    I'm using Jboss 3.2 with a mysql-ds.xml data source file

    having seperate 2 applications:

    1. AdminReportGen: Calculates results and serializes them to a mysql db
    2. Reports: Displays results by retrieving serialized result objects from the db.

    I have no problems using the setObject() method, it works fine.
    However when i use the getObject() method to retrieve the serialized object, it tells me it cannot find the class. This seems stange to me because it is included in the ear file.

    The setObject methodes looks something like this(simplyfied)
    <code>
    public void insertresult(Object result){

    PreparedStatement st = new PreparedStatement(statement);
    st.setObject(2,reportresult);

    }</code>

    The getObject methodes looks something like this(simplyfied)
    <code>

    public reports[] getreports(){

    rs = st.executeQuery ();
    List list = new ArrayList ();

    while (rs.next ()) {

    Report report = new Report ();
    report.setResult(rs.getObject("reportresult"));
    list.add (report);
    }
    </code>

    this is the error i get from the msql jdbc driver

    java.sql.SQLException: Class not found: java.lang.ClassNotFoundException: Result while reading serialized object
    at com.mysql.jdbc.ResultSet.getObject(ResultSet.java: 1508)
    at com.mysql.jdbc.ResultSet.getObject(ResultSet.java: 1550)

    Anyone who knows a solution? I seem to have run out of options.

    Regards and grtz,

    Idle,

  3. #3
    Join Date
    Mar 2004
    Posts
    1

    Re: Persisting of Java Objects using setObject()/getObject()

    Originally posted by Idle
    Hi,

    Currently i'm trying to serialize a object into a mySql db using the setObject() and the getObject() methods.

    However when i use the getObject() method to retrieve the serialized object, it tells me it cannot find the class. This seems stange to me because it is included in the ear file.

    I've found this, too, and when I compiled some tracers into com.mysql.jdbc.ResultSet, the problem went away. The issue seems to be that when the mysql-connector-java jar is in jre/lib/ext, it's not possible to load up classes in the classpath. It seems this is a Java issue. Not sure what the workaround is. It may be a security issue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •