I am trying to write a super-simple .java standalone app that looks up a JBoss JNDI-hosted ConnectionFactory (configured as JCA Resource). The ConnectionFactory (named 'IVTCF' and visible in my JBoss AS 5 Admin Console under Resource-->ConnectionFactory) is also configured (via a Resource Adapter) to JCA-connect to an IBM WS MQ hosted Queue.
First step, to confirm that my JBoss AS 5 instance's JCA-connection plumbing to WS MQ was in working order, I installed IBM's WS MQ JCA Resource Installation and Verification Test (IVT) application (wmq.jmsra.ivt.ear) on my JBoss 5.1 AS instance.
Second step, I ran the IBM IVT app's Servlet example (which also looks up the exact same JBoss JNDI hosted 'IVTCF' ConnectionFactory) and confirmed that 'IVTCF' correctly uses the configured JCA adapter to produce a Message on an IBM WS MQ hosted Queue.
Thrid step, I ran the IBM IVT app's MDB example and confirmed that a JBoss deployed MDB can also consume Messages (via JCA) published to the exact same IBM WS MQ Queue.
But I can't get my super-simple .java code's JNDI lookup of the exact same JBoss JNDI hosted 'IVTCF' ConnectionFactory to return a non-NULL value!
Unfortunately, I don't have the IBM IVT.ear's .java source code so I don't have any explicit example of how this can be exactly written with (verified to be working) .java code.
Here is my super-simple .java code.
Properties props = new Properties(); props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory"); props.setProperty(Context.PROVIDER_URL,"jnp://10.4.164.105:11099"); Context ctx = new InitialContext(props); javax.jms.ConnectionFactory factory = (javax.jms.ConnectionFactory)ctx.lookup("IVTCF"); // 'factory' always value = NULL at his time, why? System.out.println("'IVTCF' ConnectionFactory established! IVTCF=["+factory+"]"); //NPE Connection conn = factory.createConnection();
This code uses the exact same 'IVTCF' ConnectionFactory bound in my JBoss JNDI tree, but the runtime value of the JNDI lookup's 'factory' assignment is always NULL. And thus the last line of this code is always an NPE.
Any suggestions on what I am doing wrong?