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

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

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


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to