0 Replies Latest reply on Apr 26, 2002 7:07 PM by norm

    java.io.NotSerializableException

    norm Newbie

      Hello,

      I'm using jboss2.4.4 with catalina. I'm running a simple statless session bean to create a connection to my database. When I use the session bean I get this error:

      java.lang.reflect.UndeclaredThrowableException
      at $Proxy1.getConnection(Unknown Source)
      at com.pearson.testdb.session.DBConnClient.main(DBConnClient.java:26)
      Caused by: java.io.NotSerializableException: oracle.jdbc.driver.OracleConnection
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
      at java.rmi.MarshalledObject.(MarshalledObject.java:92)
      at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:410)

      here is my Bean code:

      package com.pearson.testdb.session;

      import java.rmi.RemoteException;
      import java.util.*;
      import javax.ejb.*;
      import javax.naming.*;
      import javax.jms.*;
      import javax.sql.*;
      import java.sql.*;
      import java.io.Serializable;

      public class DBSessionBean implements SessionBean{
      SessionContext sc = null;
      java.sql.Connection conn = null;
      transient javax.sql.DataSource source=null;

      public void setSessionContext(SessionContext sc) {
      this.sc = sc;
      }

      public void ejbCreate() {
      }

      public java.sql.Connection getConnection() throws RemoteException{

      try{
      Context context = new InitialContext();
      source = (DataSource)context.lookup("java:/OracleDS");
      conn = source.getConnection();
      }
      catch(javax.naming.NamingException e){
      e.printStackTrace(System.out);
      }
      catch(java.sql.SQLException e){
      e.printStackTrace(System.out);
      }
      return conn;
      }

      public void ejbRemove(){
      }
      public void ejbActivate(){}
      public void ejbPassivate(){source=null;}
      }

      How do make this datasource serializable?

      Thanks
      Norm