2 Replies Latest reply on Dec 27, 2004 4:08 AM by andrzejros

    Throwable from unregisterConnection

    andrzejros

      Hi!

      This topic have been covered, but i have a little bit different problem: I have my own JCA adapter to EIS called ECS and when i'm invoking such code using sevlet everything works fine, but when I try to put it in Stateless EJB container throws an exception (stripped try - catch statements):

      ConnectionFactory cFactory;

      ECSConnectionSpecImpl connectionSpec = new ECSConnectionSpecImpl("ecsdev", 4449);

      Connection conn = null;

      ECSInteractionSpec interactionSpec = new ECSInteractionSpec();
      RecordFactory rFactory = null;
      Interaction interaction = null;
      IndexedRecord input = null;

      conn = factory.getConnection(connectionSpec);

      rFactory = factory.getRecordFactory();
      interaction = conn.createInteraction();

      input = rFactory.createIndexedRecord("noop");
      interactionSpec.setFunctionName(ECSInteractionSpec.CMD_NOOP);
      interaction.execute(interactionSpec, input);
      interaction.close();

      conn.close();

      input = null;
      rFactory = null;
      interactionSpec = null;
      conn = null;

      After throwable is message about closing connection for you, but connection is closed

      bean is configured as transaction demarcation by container all methods of bean are signed as NotSupported for transaction support and JCA connector as no-tx

      which traces from log can help in 'investigation'?

        • 1. Re: Throwable from unregisterConnection
          darranl

          Where would your try catch statements go?
          Why did you strip them, they are a very important part of the code.
          Is your close in a finally block?

          • 2. Re: Throwable from unregisterConnection
            andrzejros

             

            "darranl" wrote:
            Where would your try catch statements go?
            Why did you strip them, they are a very important part of the code.
            Is your close in a finally block?



            here it goes ...

             ConnectionFactory cFactory;
            
             ECSConnectionSpecImpl connectionSpec = new ECSConnectionSpecImpl("host", port);
            
             Connection conn = null;
            
             ECSInteractionSpec interactionSpec = new ECSInteractionSpec();
             RecordFactory rFactory = null;
             Interaction interaction = null;
             IndexedRecord input = null;
            
             try
             {
             conn = factory.getConnection(connectionSpec);
             } catch (ResourceException ex)
             {
             throw new RemoteException("unable to obtain connection from factory");
             }
            
             try
             {
             rFactory = factory.getRecordFactory();
             interaction = conn.createInteraction();
            
             input = rFactory.createIndexedRecord("noop");
             interactionSpec.setFunctionName(ECSInteractionSpec.CMD_NOOP);
             interaction.execute(interactionSpec, input);
             interaction.close();
            
             } catch (ResourceException ex)
             {
             throw new RemoteException("unable to send noop command");
             } finally
             {
             if (logger.isDebugEnabled())
             {
             logger.debug("noop() - finally");
             }
            
             if (conn != null)
             {
             try
             {
             conn.close();
             } catch (ResourceException ex1)
             {
             }
             }
             input = null;
             rFactory = null;
             interactionSpec = null;
             conn = null;
             }