I have created a -ds.xml file and placed it in
%JBOSS_HOME%/server/default/deploy directory. This ds file contains the
configuration of a connection factory and i have pointed it to jms-ra.rar by
setting the rar-name as follows:
<?xml version="1.0" encoding="UTF-8"?>
|
| <connection-factories>
|
| <tx-connection-factory>
| <jndi-name>TestRA</jndi-name>
| <xa-transaction/>
| <rar-name>jms-ra.rar</rar-name>
| <use-java-context>false</use-java-context>
|
<connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
| <config-property name="SessionDefaultType"
type="java.lang.String">javax.jms.Topic</config-property>
| <config-property name="JmsProviderAdapterJNDI"
type="java.lang.String">java:/DefaultJMSProvider2</config-property>
| <max-pool-size>20</max-pool-size>
|
<security-domain-and-application>JmsXARealm</security-domain-and-application>
| </tx-connection-factory>
|
| </connection-factories>
This is just a sample connection factory which i have created as a test.
Note that i have set "use-java-context" attribute to false, so that this can be
looked up from outside the appserver JVM.
The ds file deploys fine and the jndi name gets bound to the global namespace
as expected. Here's the output from the jmx-console:
anonymous wrote : Global JNDI Namespace
| +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
| +- jmx (class: org.jnp.interfaces.NamingContext)
| | +- invoker (class: org.jnp.interfaces.NamingContext)
| | | +- RMIAdaptor (proxy: $Proxy47 implements interface
org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface
org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
| | +- rmi (class: org.jnp.interfaces.NamingContext)
| | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class:
javax.naming.LinkRef)
| +- HTTPXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
| +- TestRA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
However, when i do a lookup of the jndi name "TestRA" from a standalone java
client, the object returned is NULL. Note that there are no NameNotFound or any
other such exceptions. Just to make sure that my jndi lookup code was not
wrong, i did a lookup of another object which was present in the Global
namespace(i.e. UserTransaction) and i got the correct reference of the object.
The code, hence, does not look to be wrong. Here's the standalone client code:
package org.myapp;
|
| import javax.naming.Context;
| import javax.naming.InitialContext;
|
| public class TestLookup {
|
| /**
| * @param args
| */
| public static void main(String[] args) {
| try {
|
| Context ctx = new InitialContext();
| Object ref = ctx.lookup("TestRA");
| if (ref==null) {
| System.out.println("My connection factory is
null");
| /*
| * Try looking up some other object in global
JNDI namespace
| *
| */
| Object anotherObj =
ctx.lookup("UserTransaction");
| if (anotherObj == null) {
| System.out.println("Could *not* lookup
even this object. Something wrong with setup or code");
| } else {
| System.out.println("Successfull lookup
of the other object from the jndi: " + anotherObj);
| System.out.println("Why is lookup of my
connection factory failing");
| }
| } else {
| System.out.println("My connection factory is
*not* null: " + ref);
| }
|
|
|
| } catch(Exception e) {
| e.printStackTrace();
| }
| }
|
| }
Why is it that i am getting a NULL when i lookup the connection factory?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960911#3960911
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960911
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user