2 Replies Latest reply: Aug 6, 2011 11:08 PM by kiran.kumar M RSS

    ManagedConnectionFactory Life Cycle

    kiran.kumar M Newbie

      Hi,

      I deploy the rar file by placing it in the deployment folder in jboss as 7. Later deploy my war file.

      This connector in bound to a jNDI location by definition inside standalone.xml.

      When it is deployed the createConnectionFactory(ConnectionManager cm) is executed by default.

      I do some house keeping with help of  ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();

       

      This method is again executed when i try to access the adapter using an ejb.

      Problem is initally at the time of loading the classloader is null. Later it has a value when called from ejb. Effectively my housekeeping fails.

       

      Question :

      1) createConnectionFactory(ConnectionManager cm) is executed at the time of deployment => is this the proper behaviour ?

      2) How can I configure ironJacamar not to execute this method at the time of deployment ?

       

      Thanks

        • 1. Re: ManagedConnectionFactory Life Cycle
          Jesper Pedersen Master

          When it is deployed the createConnectionFactory(ConnectionManager cm) is executed by default.

           

          Of course - that is the way the ConnectionFactory is created, and bound into JNDI.

           

          I do some house keeping with help of  ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();

           

          You should never use the thread context classloader. Use the classloader that defined your deployment:

           

          ClassLoader cl = MyManagedConnectionFactory.class.getClassLoader();
          

           

          This method is again executed when i try to access the adapter using an ejb.

          Problem is initally at the time of loading the classloader is null. Later it has a value when called from ejb. Effectively my housekeeping fails.

           

          Are you sure, that it is the same ConnectionFactory that you reference ? Post your ra.xml and <resource-adapter> subsystem. And what the EJB does...

           

          And "housekeeping" sounds very scary to me... Post your code

          • 2. Re: ManagedConnectionFactory Life Cycle
            kiran.kumar M Newbie

            Thanks jesper it worked. Basically the classloader used at the time of deployment has to be same as the one used at runtime. So now I pass

            ClassLoader cl = MyManagedConnectionFactory.class.getClassLoader();