6 Replies Latest reply on Dec 27, 2001 2:55 PM by dkmarley

    Calling EJB Method Affects ServerSocket on Client

    dkmarley

      I have written a multi-threaded server application that accepts requests from remote clients and calls methods on EJBs deployed on jBoss which is running on a separate machine.

      I have tested the server code independantly of EJB calls and it all works fine. When I call an EJB method, however, ServerSocket.accept() refuses to accept any further connections until the EJB method call(running in a separate thread) completes.

      Any suggestions gratefully received.

        • 1. Re: Calling EJB Method Affects ServerSocket on Client
          ipozeng

          I think you need to put ServerSocker accept on another thread.Because EJB call defaults to synchronous which means the call will not reture until EJB finish its running !

          Best Regards!

          • 2. Re: Calling EJB Method Affects ServerSocket on Client
            dkmarley

            JBoss 2.4.3 (WindowsNT & RedHat 6.2)

            ServerSocket.accept() is running in a separate thread according to the usual implementation of multi-threaded server applications in Java.

            A new thread is being created to process each socket returned from ServerSocket.accept(). The socket is then
            read and closed before the call to the EJB method.

            • 3. Re: Calling EJB Method Affects ServerSocket on Client

              Hi,

              Have you tried replacing the EJB call with

              Thread.currentThread().sleep(1000);

              this should make sure it is not your code. :-)

              Regards,
              Adrian

              • 4. Re: Calling EJB Method Affects ServerSocket on Client
                dkmarley

                Hi Adrian

                Yes, I've done precisely that and various other tests. When testing, I can accept and process multiple concurrent connections without any problems.

                As soon as I call any EJB method from one of the spawned threads, however, ServerSocket.accept() refuses to accept any further connections for the duration of the method call.

                David Marley

                • 5. Re: Calling EJB Method Affects ServerSocket on Client

                  Hi,

                  I don't know what's wrong then.

                  Can you post your code? Or a small test program with
                  the same problem?

                  Alternatively, have a look at the Tomcat/Jetty contributions to JBoss. They are doing the same you
                  (except perhaps local EJB calls) without this problem.

                  Regards,
                  Adrian

                  • 6. Re: Calling EJB Method Affects ServerSocket on Client
                    dkmarley

                    Hi Adrian

                    Sorry I've taken so long to reply. I have discovered what the problem is and I have rectified it.

                    The problem was with my EJBs on the server. I have a session bean that generates unique IDs for entity beans and this was(every 200 invocations) obtaining a Connection from the pool and calling Connection.setTransaction(TRANSACTION_SERIALIZABLE). before obtaining a new starting ID. The failure to reset the transaction level before returning the Connection to the pool was resulting in a pool with, eventually, every Connection set to TRANSACTION_SERIALIZABLE.

                    My apparently limited knowledge of transations prevents me from understanding why this should affect code running in a different thread on the client.

                    Any ideas?

                    David