users@glassfish.java.net

Re: Can I inject a JCA Connection Factory?

From: <glassfish_at_javadesktop.org>
Date: Tue, 09 Oct 2007 18:00:07 PDT

OK, I've found what the problem is. On line 571 of NamingManagerImpl, there's the line

            else if (isConnector(logicalJndiName)) {

So, it's checking the logical JNDI name, to see if it has the String "/eis/" in it. In my particular case, the logical name was

java:comp/env/mySVConnector

Using that logical value, I was getting the error because the Naming manager was not treating the object being bound as a Connector. But, if I change my resource declaration from

    @Resource(name="mySVConnector", mappedName="jca/SVConnector1")

to
    @Resource(name="eis/mySVConnector", mappedName="jca/SVConnector1")

then everything works just fine. So, the isConnector method looks like

    private boolean isConnector(String logicalJndiName){
            return (logicalJndiName.indexOf(EIS_STRING)!=-1);
    }


This functionality makes the assumtion that the logical name will contain "/eis/" somewhere in it.

Wouldn't it be better if it checked the resource type to be javax.resource.cci.ConnectionFactory? In fact, the class ResourceReferenceDescriptor object has such a method called isResourceConnectionFactory(). So, change the original line

            else if (isConnector(logicalJndiName)) {

to

            else if (next.isResourceConnectionFactory()) {

This way, it's not dependant on the logical name of the resource reference?
[Message sent by forum member 'hildo' (hildo)]

http://forums.java.net/jive/thread.jspa?messageID=239223