Search code examples
javajakarta-eejbossjboss7.xjca

How to manage the life cycle of JCA ManagedConnectionFactory?


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 in this method with help of classloader

ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();

The createConnectionFactory(ConnectionManager cm) method is again executed when I try to access the adapter using an ejb

Problem is initially at the time of deploying the contextClassLoader 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/jboss not to execute this method at the time of deployment ?

Other info : Jboss As7, NetBeans 7 , Jdk1.7

Edit : The above behavior is correct. The adapter I am using requires that the classloader used at the time of deployment has to be same as the one used at runtime. By default it uses Thread.currentThread().getContextClassLoader(). I changed it to use ClassLoader cl = MyManagedConnectionFactory.class.getClassLoader();


Solution

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

    If you have a ConnectionFactory definition then I would expect to see this method called, as the container creates and binds a ConnectionFactory definition in the JNDI namespace - the fact that you're getting the call taking a ConnectionManager shows that this is executing in the managed scenario.

    Chapter six of the JCA specification describes this area of a resource adapter in a lot of detail, so I would have thought a definitive answer is there. edit: chapter 17 is also likely relevant.