2 Replies Latest reply on Nov 23, 2004 11:11 AM by Gary Moore

    WrappedConnection NotSerializableException

    Gary Moore Newbie

      Just upgraded from 3.0.6 to 4.0

      Have a number of EJB's that start a transaction and pass the connection over to other EJB's.

      Receiving the error:
      java.io.NotSerializableException: org.jboss.resource.adapter.jdbc.WrappedConnection

      I do understand that connections are not serializable and we are beginning the process to modify our code accordingly.

      What I would like to know is why this same code worked under 3.0.6? Was this something that earlier versions allowed and should not of? We did not change our driver - jConnect 5.2, nor change our jdk - 1.4.2_04. The only change was creating a -ds.xml file based on our -service.xml file.

      Any help or direction would be appreciated.

      Thanks in advance


        • 1. Re: WrappedConnection NotSerializableException
          Adrian Brock Master

          Use a local interface then you will get call-by-reference semantics
          rather than call-by-value semantics.

          It's all explained on the wiki including the JBoss4FAQ about the change to default
          config to use call-by-value by default.

          Passing managed connections between ejb contexts is usually a bad idea
          anyway - unless you really know what you are doing - e.g. you are making
          assumptions about the transaction assembly that may not be valid.

          You are nearly always better off asking for a connection when you need it
          and closing it once you have finished. This allows the greatest chance
          of using resources efficiently and gives the server admin the most control.

          Try the following piece of code that shows you always get the same connection
          in the same transaction (regardless of who asks for it) with the default config.

          Connection c = dataSource.getConnection();
          try
          {
          WrappedConnection wc = (WrappedConnection) c;
          System.out.println(wc.getUnderlyingConnection());
          }
          finally
          {
          c.close();
          }
          


          • 2. Re: WrappedConnection NotSerializableException
            Gary Moore Newbie

            Adrian,

            Thanks for the assistance.