1 Reply Latest reply on Jul 19, 2011 6:53 PM by Clebert Suconic

    Can't find ConnectionFactory

    DJ Spiess Newbie



      I'm creating the message producer in a JMS client app a little different than the examples.  I'm trying to use injection with the Java annotations. This is what I'm trying to use to post messages to a queue.



      public class HornetProducer {
                private static ConnectionFactory connectionFactory;
              private static Queue queue;
                 * @param args
                public static void main(String[] args) {
                          Connection connection;
                          try {
                                    connection = connectionFactory.createConnection();
                                    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                                    MessageProducer producer = session.createProducer(queue);
                                    TextMessage message = session.createTextMessage();
                                    for (int i = 0; i < 10; i++) { 
                                        message.setText("This is message " + (i + 1)); 
                                        System.out.println("Sending message: " + message.getText()); 
                                      // end message
                          } catch (JMSException e) {


      I'm running HornetQ as a standalone app.  I've created a queue and connection factory in hornetq-jms.xml as listed below


      <connection-factory name="ConnectionFactory"> 
                <connector-ref connector-name="netty"/> 
                <entry name="ConnectionFactory"/> 
      <queue name="Queue"> 
          <entry name="/queue/Queue"/>


      When I try running this, it looks like the connection factory and queue are never injected.  The connection factory is null when it's trying to create a connection.


      I also created a jndi.properties file, and put it in the classpath.


      Is there something I'm missing?  Is there something else I need to configure?



      DJ Spiess