2 Replies Latest reply on Mar 27, 2007 4:15 AM by Andre Fritsch

    ConnectionFactory not bound

    pedro costa Apprentice

      I've read all related posts, but i didn't get the solution for my problem.

      I've this file:

      ServerQueue.java

      package com.sample.queue;
      
      /**
       * Receives client messages and starts workflows
       */
      import org.apache.log4j.Logger;
      
      import com.sample.xmlbinding.XMLBinding;
      
      import java.io.InputStream;
      import java.io.PipedInputStream;
      import java.io.PipedOutputStream;
      import java.io.PrintStream;
      import java.io.Serializable;
      
      import java.util.Properties;
      import java.util.regex.Matcher;
      import java.util.regex.Pattern;
      
      import javax.jms.JMSException;
      import javax.jms.Message;
      import javax.jms.MessageListener;
      import javax.jms.Queue;
      import javax.jms.QueueConnection;
      import javax.jms.QueueConnectionFactory;
      import javax.jms.QueueReceiver;
      import javax.jms.QueueSession;
      import javax.jms.Session;
      import javax.jms.TextMessage;
      
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      
      public class ServerQueue implements MessageListener, Serializable {
      
       private static final long serialVersionUID = 4L;
      
       private static final Logger logger = Logger.getLogger(ServerQueue.class);
      
       private InitialContext ctx;
       private QueueConnectionFactory qcf;
       private Queue queue;
       private QueueConnection qc;
       private QueueSession qs;
       private QueueReceiver qr;
      
      
       public void init(){
      
       Properties properties = new Properties();
      
       properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
       properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
       properties.put(Context.PROVIDER_URL, "localhost");
      
       try {
      
      
       ctx = new InitialContext(properties);
      
       System.out.println("Passou");
       System.out.println("-------------------");
      
       logger.info("Looking up connection factory");
       qcf = (QueueConnectionFactory) ctx.lookup("UIL2ConnectionFactory");
      
      
       logger.info("Looking up queue");
       queue = (Queue)ctx.lookup("queue/testQueue");
      
       logger.info("Creating queue connection");
      
       qc = qcf.createQueueConnection();
      
       qc.start ();
      
       logger.info("Creating queue session: not transacted, auto ack");
       qs = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      
       logger.info("Creating queue, subscriber");
       qr = qs.createReceiver(queue);
      
       logger.info("Ready to subscribe for messages :");
      
       qr.setMessageListener (this);
       } catch (NamingException ex) {
       logger.error("Server.init: ", ex);
       ex.printStackTrace();
       } catch (JMSException ew) {
       logger.error("Server.init: ", ew);
       ew.printStackTrace();
       }
       }
      
       /**
       * MessageListener interface method
       */
       public void onMessage(Message message)
       {
       TextMessage msg = null;
       String textMsg = null;
      
       try {
       msg = (TextMessage) message;
       textMsg = msg.getText();
       logger.info(textMsg);
       System.out.print(textMsg);
      
       } catch (JMSException e) {
       // TODO Auto-generated catch block
       logger.error("Server.onMessage: ", e);
       }
      
       InputStream inputstream = getInputStream(textMsg);
      
       XMLBinding xmlbinding = new XMLBinding();
      
       String typeoccurrence = xmlbinding.unmarshall(inputstream)
       .getTypeoccurrence();
      
       int id = getOccurrenceID(inputstream);
      
       System.out.println("---------------");
       System.out.print(typeoccurrence);
       System.out.print(id);
       }
      
       private InputStream getInputStream(String msg) {
       PipedOutputStream ps = null;
       PipedInputStream is = null;
      
       try {
       ps = new PipedOutputStream();
       is = new PipedInputStream(ps);
       PrintStream os = new PrintStream(ps);
       os.write(msg.getBytes());
       os.close();
       } catch (Exception e) {
       logger.error("Server.getInputStream: " + e);
       }
      
       return is;
       }
      
       private int getOccurrenceID(InputStream in){
       int id = 0;
      
       System.out.println(in.toString());
       return id;
       }
       /**
       * Checks if a searchField field exists in the Message message
       * @param message Received message
       * @param searchField Field to search in the Message
       * @return true if founds the action, otherwise false
       */
       public boolean parseMessage(String message, String searchField)
       {
       Pattern p = Pattern.compile(searchField);
       Matcher m = p.matcher(message);
      
       if(m.find()) return true;
      
       return false;
       }
      }
      




      When i try run this class, it gives me the error:



      javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: ConnectionFactory not bound]
       at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1052)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:685)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
       at javax.naming.InitialContext.lookup(Unknown Source)
       at com.sample.queue.ServerQueue.init(ServerQueue.java:70)
       at com.sample.jbpm.Server.main(Server.java:14)
      Caused by: javax.naming.NameNotFoundException: ConnectionFactory not bound
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:514)
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:522)
       at org.jnp.server.NamingServer.getObject(NamingServer.java:528)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:281)
       at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
       at sun.rmi.transport.Transport$1.run(Transport.java:153)
       at java.security.AccessController.doPrivileged(Native Method)
       at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
       at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
       at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
       at java.lang.Thread.run(Thread.java:595)
       at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
       at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
       at sun.rmi.server.UnicastRef.invoke(Unknown Source)
       at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
       at javax.naming.InitialContext.lookup(Unknown Source)
       at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1046)
       ... 5 more
      



      I didn't modified the uil2-service.xml. The jmx-console detects the connection factory and the testQueue.

      I don't understand why jboss AS-4.0.3SP1 doesn't read the xml file and bound ConnectionFactory. Anyone can explain?

      Should i setup QueueConnectionFactory and queue/testQueue somewhere else?



      Thanks,
      Pedro

        • 1. Re: ConnectionFactory not bound
          pedro costa Apprentice

          When i start the AS, i get the following error:

          javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
           at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1302)
           at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1431)
           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:579)
           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
           at javax.naming.InitialContext.lookup(InitialContext.java:351)
           at org.jboss.ejb3.EJB3Deployer.initializeJavaComp(EJB3Deployer.java:148)
           at org.jboss.ejb3.EJB3Deployer.startService(EJB3Deployer.java:135)
           at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:274)
           at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:230)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
           at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:943)
           at $Proxy0.start(Unknown Source)
           at org.jboss.system.ServiceController.start(ServiceController.java:428)
           at org.jboss.system.ServiceController.start(ServiceController.java:446)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
           at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
           at $Proxy4.start(Unknown Source)
           at org.jboss.deployment.SARDeployer.start(SARDeployer.java:285)
           at org.jboss.deployment.MainDeployer.start(MainDeployer.java:989)
           at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:790)
           at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:753)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
           at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
           at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
           at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
           at $Proxy6.deploy(Unknown Source)
           at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:319)
           at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:507)
           at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:192)
           at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:265)
           at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:274)
           at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:230)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
           at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:943)
           at $Proxy0.start(Unknown Source)
           at org.jboss.system.ServiceController.start(ServiceController.java:428)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
           at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
           at $Proxy4.start(Unknown Source)
           at org.jboss.deployment.SARDeployer.start(SARDeployer.java:285)
           at org.jboss.deployment.MainDeployer.start(MainDeployer.java:989)
           at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:790)
           at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:753)
           at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:737)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
           at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
           at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
           at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
           at $Proxy5.deploy(Unknown Source)
           at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:453)
           at org.jboss.system.server.ServerImpl.start(ServerImpl.java:330)
           at org.jboss.Main.boot(Main.java:187)
           at org.jboss.Main$1.run(Main.java:438)
           at java.lang.Thread.run(Thread.java:595)
          Caused by: java.net.SocketTimeoutException: Receive timed out
           at java.net.PlainDatagramSocketImpl.receive0(Native Method)
           at java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:136)
           at java.net.DatagramSocket.receive(DatagramSocket.java:712)
           at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1272)
           ... 103 more
          



          • 2. Re: ConnectionFactory not bound
            Andre Fritsch Newbie

            Hi!

            I have a similar problem! Did you solve your´s? If yes, how?

            Best regards,

            André