JMS5007: Illegal connection factory access

Hi,

I'm getting this warning when my MDB is creating a connection to a queue to start consuming messages (onMessage method). The application works, but I'd like to know what this message really means and how to avoid it:

JMS5007: Illegal connection factory access to [jms/InteractionTrackerQCF]. J2EE Components should access JMS Connection Factories through a resource-ref in java:comp/env

My ejb-jar.xml is as follow:

<ejb-jar>

<display-name>InteractionTrackerJAR</display-name>

<enterprise-beans>

<message-driven>

<display-name>InteractionTrackerEJB</display-name>

<ejb-name>InteractionTrackerEJB</ejb-name>

<ejb-class>com.xxxxxx.InteractionTrackerBean</ejb-class>

<transaction-type>Bean</transaction-type>

<acknowledge-mode>Auto-acknowledge</acknowledge-mode>

<message-driven-destination>

<destination-type>javax.jms.Queue</destination-type>

</message-driven-destination>

<resource-ref>

<res-ref-name>jms/InteractionTrackerQCF</res-ref-name>

<res-type>javax.jms.QueueConnectionFactory</res-type>

<res-auth>Container</res-auth>

<res-sharing-scope>Shareable</res-sharing-scope>

</resource-ref>

<resource-env-ref>

<resource-env-ref-name>jms/InteractionTracker</resource-env-ref-name&g t;

<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>

</resource-env-ref>

</message-driven>

</enterprise-beans>

</ejb-jar>

and my sun-ejb-jar.xml is

<sun-ejb-jar>

<enterprise-beans>

<ejb>

<ejb-name>InteractionTrackerEJB</ejb-name>

<jndi-name>jms/InteractionTracker</jndi-name>

<resource-ref>

<res-ref-name>jms/InteractionTrackerQCF</res-ref-name>

<jndi-name>jms/InteractionTrackerQCF</jndi-name>

</resource-ref>

<resource-env-ref>

<resource-env-ref-name>jms/InteractionTracker</resource-env-ref-name&g t;

<jndi-name>jms/InteractionTracker</jndi-name>

</resource-env-ref>

<mdb-connection-factory>

<jndi-name>jms/InteractionTrackerQCF</jndi-name>

</mdb-connection-factory>

<jms-max-messages-load>1</jms-max-messages-load>

<is-read-only-bean>false</is-read-only-bean>

<gen-classes />

</ejb>

</enterprise-beans>

</sun-ejb-jar>

In my application server instance, I've created a Connection Factory entry and a Destination Resource with the correct jndi names (and the imqDestinationName property).

Does anyone know how to resolve this problem?

Thanks

miki

[3009 byte] By [706031] at [2008-2-26]
# 1

Hi Miki,

I think I have a guess as to why you are seeing:

JMS5007: Illegal connection factory access to [jms/InteractionTrackerQCF]. J2EE Components should access JMS Connection Factories through a resource-ref in java:comp/env

[ I just did some tests and got the same results/error msg ]

Your application depends on 2 JMS resources located at:

jms/InteractionTrackerQCF

jms/InteractionTracker

You mention that you have created these resources with the correct

JNDI names. I suspect your code may be looking up these

resources via something like:

jndiContext.lookup("jms/InteractionTrackerQCF");

The J2EE spec says applications should lookup resources via

something like:

jndiContext.lookup("java:comp/env/jms/InteractionTrackerQCF");

I notice that if I omit the java:comp/env/ from my lookup

string, the app still works but I get the error msg.

Can you try adding java:comp/env/ to your lookup string ?

regards,

-i

Guest at 2007-7-1 > top of java,Application & Integration Servers,Sun Java System Message Queue...
# 2

Hi Isa,

thanks a lot for your reply. I've tried to change the way I'm looking up for things in the jndi context but I had no success.

If I update the *client* code, that's the code that creates the messages and I put the complete java:comp/env/jms/InteractionTrackerQCF and java:comp/env/jms/InteractionTracker I get an exception (javax.naming.NameNotFoundException: No object bound to name java:comp/env/jms/InteractionTrackerQCF)

If I update the ejb deployment descritptor to use java:comp/env/jms/InteractionTracker as <jndi-name> element of the <mdb-connection-factory> tag I get the following exception:

javax.naming.NamingException: invocation exception

at com.sun.enterprise.naming.NamingManagerImpl.getComponentId(NamingMana

gerImpl.java:990)

at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.

java:789)

at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.j

ava:107)

at javax.naming.InitialContext.lookup(InitialContext.java:347)

at com.sun.ejb.containers.MessageBeanHelperBase.checkConnectionFactoryOb

ject(MessageBeanHelperBase.java:490)

at com.sun.ejb.containers.MessageBeanHelperBase.setup(MessageBeanHelperB

ase.java:374)

at com.sun.ejb.containers.MessageBeanContainer.<init>(MessageBeanContain

er.java:206)

at com.sun.ejb.containers.ContainerFactoryImpl.createContainer(Container

FactoryImpl.java:173)

at com.iplanet.ias.server.AbstractLoader.loadEjbs(AbstractLoader.java:34

5)

at com.iplanet.ias.server.ApplicationLoader.load(ApplicationLoader.java:

81)

at com.iplanet.ias.server.AbstractManager.load(AbstractManager.java:134)

at com.iplanet.ias.server.ApplicationLifecycle.onStartup(ApplicationLife

cycle.java:147)

at com.iplanet.ias.server.ApplicationServer.onStartup(ApplicationServer.

java:269)

at com.iplanet.ias.server.J2EERunner.confPostInit(J2EERunner.java:162)

Any other idea on what I can do about this?

Thanks

miki

706031 at 2007-7-1 > top of java,Application & Integration Servers,Sun Java System Message Queue...
# 3

Hi Miki,

A couple things to note and a question:

The deployment descriptors do not use the java:comp/env/ syntax.

From your example, the jndi names in your deployment XMLs should

contain strings like jms/InteractionTracker and

jms/InteractionTrackerQCF

When you use asadmin or the web administration GUI to create

these JMS resources, use jms/InteractionTracker and jms/InteractionTrackerQCF as the JNDI names - don't use the

java:comp/env/ syntax.

Where is your client code running ? Is it in a servlet ? In any case,

it needs to perform the lookup using the java:comp/env/ syntax. This is

the only place where you'll see this syntax used - in source.

I spent about 20 minutes debugging my example prior to replying

to you yesterday before finding out that I had spelled my jndi

names wrong (actually used lower instead of upper case).

regards,

-i

Guest at 2007-7-1 > top of java,Application & Integration Servers,Sun Java System Message Queue...
# 4

Hi,

thanks a lot for your support... The amounf of time you're spending on this issue is really appreciated.

I'm sorry about the confusion about the names (jms/InteractionTracker rather than comp/env/jms/InteractionTracker - I tried changing things in the app to solve the problem)

Anyway, I'm back to the initial configuration: from the SunONE admin console I've created 2 jms resources (jms/InteractionTracker and jms/InteractionTrackerQCF). In my ejb deplouyment descriptor I've created resources for jms/InteractionTrackerQCF and jms/InteractionTracker and all the jndi names use jms/InteractionTrackerQCF and jms/InteractionTracker.

My client code (a normal class) is called within a JSP. If the client uses the standard jms/InteractionTrackerQCF and jms/InteractionTracker, everything works but I get the JMS5007 error. If the client uses the full java:comp/env/ syntax, I get a javax.naming.NameNotFoundException: No object bound to name java:comp/env/jms/InteractionTrackerQCF.

I don't understand why I'm getting these problems. I start wondering if it's a bug with the vesion of the app server I'm using (that's 7.0 on solaris).

Regards

Miki

706031 at 2007-7-1 > top of java,Application & Integration Servers,Sun Java System Message Queue...