users@glassfish.java.net

Re: Can I inject a JCA Connection Factory?

From: Sivakumar Thyagarajan <Sivakumar.Thyagarajan_at_Sun.COM>
Date: Mon, 08 Oct 2007 17:43:17 +0530

Hi

J2EE Connector CFs can ideally be injected. Do you have a connector resource
bound to "jca/SVConnector1"? Could you provide your domain.xml [after creating
the connector connection pool, resources] and a snippet of your bean so that I
can investigate this further?

Thanks
--Siva

glassfish_at_javadesktop.org wrote:
> Hi all. I'm testing a JCA adapter I've written in a Glassfish v2 UR1 B01 instance. And it's deployed, and I've successfully defined a few connection pools.
>
> Now I'm attempting to use the ConnectionFactory of one of the Pools in a Stateless session bean. If I write the Session Bean to use a Context instance to perform a lookup on the jndi name as it is configured in Glassfish (the non-portable way), it works fine.
>
> However, when I try to use inject the resource, I get an error. First, I've written my bean as
>
> @Stateless(mappedName="sv/MySession")
> public class MySessionBean implements MySessionRemote, MySessionLocal {
>
> @Resource(name="mySVConnector", mappedName="jca/SVConnector1")
> private ConnectionFactory connectionFactory;
>
>
> From my understanding, we have the entry "java:comp/env/mySVConnector" that will be used by the code, and which will be mapped to the value "jca/SVConnector1". I know it's more portable to define in the sun DD, but this is just a test app, and it can still be overridden by a DD even if it's defined like this.