You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Paul <pa...@mnwebhost.net> on 2005/02/03 19:24:48 UTC

Is Connector/J Serializable?

I'm setting up Tomcat 5.0.28 in a vertical two node cluster and want to 
use the in-memory session replication.  The application I'm trying to 
run on the cluster requires the db connection to be stored in a session 
object.  But I'm getting an error message that says it's not 
serializable.  I'm wondering if that is just how it is, or maybe I'm 
just doing something wrong.  Here is a snip of the code in question.

class ConnHolder implements Serializable, HttpSessionBindingListener {
  private transient Connection con = null;  // i've tried with and 
without transient
  public ConnHolder(Connection con) {
     this.con = con;
     try {
        con.setAutoCommit(false);
     } catch(SQLException e) { }
  }
  public Connection getConn() { 
     return con;    // return the connection
  }
 ...
}

Thanks in advance,

-Paul


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Is Connector/J Serializable?

Posted by Paul <pa...@mnwebhost.net>.
Forgot to mention, this is on FC3 x86_64 and I'm using the Connector/J 
connector from MySQL. 

This is from the catalina.out log,
SEVERE: ReplicatedSession: Cannot serialize session attribute connect 
for session EE7F84D18E7225BEDFFF1CC80FFAEBC6
java.io.NotSerializableException: org.gjt.mm.mysql.Connection

This is from my server.xml
<Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
    
managerClassName="org.apache.catalina.cluster.session.SimpleTcpReplicationManager"
    expireSessionsOnShutdown="false"
    useDirtyFlag="false">

I've tried, the DeltaManager and tried setting useDirty to true as well.


Paul wrote:

> I'm setting up Tomcat 5.0.28 in a vertical two node cluster and want 
> to use the in-memory session replication.  The application I'm trying 
> to run on the cluster requires the db connection to be stored in a 
> session object.  But I'm getting an error message that says it's not 
> serializable.  I'm wondering if that is just how it is, or maybe I'm 
> just doing something wrong.  Here is a snip of the code in question.
>
> class ConnHolder implements Serializable, HttpSessionBindingListener {
>  private transient Connection con = null;  // i've tried with and 
> without transient
>  public ConnHolder(Connection con) {
>     this.con = con;
>     try {
>        con.setAutoCommit(false);
>     } catch(SQLException e) { }
>  }
>  public Connection getConn() {     return con;    // return the 
> connection
>  }
> ...
> }
>
> Thanks in advance,
>
> -Paul
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org