[jboss-user] [Messaging, JMS & JBossMQ] - Creating New Connection Factory

nitinmandolkar do-not-reply at jboss.com
Sun Apr 27 15:54:00 EDT 2008


Hi All

The default connection factory name  in jbos is ConnectionFactoty, java:/ConnectionFactory, XAConnectionFactory and java:/XAConnectionFactory. 

So when ever i need to connect JBOSS JMS Server my client code need to look for above name in JNDI. Sample code below...

        InitialContext iniCtx = new InitialContext();
        Object tmp = iniCtx.lookup("java:/ConnectionFactory");
        QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;

With above code block my example is working fine with out any problem.

Due to old code base i can not use default Connection factory name provided by JBOSS. I am intrest to give my name to connection factory. So in search of that i did some change in jms-ds.xml as below.
<!--

    DefaultJMSProvider
    
      org.jboss.jms.jndi.JNDIProviderAdapter
    
    <!-- The combined connection factory -->
    java:/MyConnectionFactory
    <!-- The queue connection factory -->
    java:/MyConnectionFactory
    <!-- The topic factory -->
    java:/MyConnectionFactory
    <!-- Uncomment to use HAJNDI to access JMS
    
       java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
       java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
       java.naming.provider.url=localhost:1100
    
    -->
  
-->
After doing this change in jms-ds.xml file i change the above code block like this. Now i am looking for  "MYConnectionFactory" rather than "ConnectionFactory".

        InitialContext iniCtx = new InitialContext();
        Object tmp = iniCtx.lookup("java:/MyConnectionFactory");
        QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;

Doing this change i am excepting it shoud work. but i am getting following error. Can one tell me where i can define new connection factory in JBOSS 4.2.2 GA and how. 

Exception i am getting :
====================
run-example1p2p:
     [java] [INFO,SendRecvClient] Begin SendRecvClient, now=1209322015968
     [java] [INFO,SendRecvClient] Begin sendRecvAsync
     [java] Exception in thread "main" javax.naming.NameNotFoundException: MyCon
nectionFactory not bound
     [java]     at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)

     [java]     at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)

     [java]     at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
     [java]     at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:585)
     [java]     at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.jav
a:294)
     [java]     at sun.rmi.transport.Transport$1.run(Transport.java:153)
     [java]     at java.security.AccessController.doPrivileged(Native Method)
     [java]     at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
     [java]     at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTranspor
t.java:466)
     [java]     at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPT
ransport.java:707)
     [java]     at java.lang.Thread.run(Thread.java:595)
     [java]     at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServe
r(StreamRemoteCall.java:247)
     [java]     at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCa
ll.java:223)
     [java]     at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
     [java]     at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
     [java]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:66
7)
     [java]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:62
7)
     [java]     at javax.naming.InitialContext.lookup(InitialContext.java:351)
     [java]     at org.jboss.book.jms.ex1.SendRecvClient.setupPTP(SendRecvClient
.java:56)
     [java]     at org.jboss.book.jms.ex1.SendRecvClient.sendRecvAsync(SendRecvC
lient.java:72)
     [java]     at org.jboss.book.jms.ex1.SendRecvClient.main(SendRecvClient.jav
a:104)
     [java] Java Result: 1



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4147080#4147080

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4147080



More information about the jboss-user mailing list