javax.jms.TopicConnectionFactory not bound的問題?

ijava發表於2004-03-05
在JBOSS\jboss-3.0.4_tomcat-4.0.6環境下做一個最簡單的JMS
Exception in thread "main" javax.naming.NameNotFoundException: javax.jms.TopicConnectionFactory not bound
執行以下的就報這個錯。
這個包有啊,怎麼才能繫結這個啊???

E:\ejbstudy\jms\classes>java -Djava.security.policy=../java.policy -Djava.naming
.factory.initial=org.jnp.interfaces.NamingContextFactory -Djava.naming.provider.
url=localhost examples.Client

examples.Client
__
package examples;

import javax.naming.*;

import javax.jms.*;
import java.util.*;

public class Client {

public static void main (String[] args) throws Exception {

// Initialize JNDI
Context ctx = new InitialContext(System.getProperties());

// 1: Lookup ConnectionFactory via JNDI
TopicConnectionFactory factory =
(TopicConnectionFactory)
ctx.lookup("javax.jms.TopicConnectionFactory");

// 2: Use ConnectionFactory to create JMS connection
TopicConnection connection =
factory.createTopicConnection();

// 3: Use Connection to create session
TopicSession session = connection.createTopicSession(
false, Session.AUTO_ACKNOWLEDGE);

// 4: Lookup Desintation (topic) via JNDI
Topic topic = (Topic) ctx.lookup("testtopic");

// 5: Create a Message Producer
TopicPublisher publisher = session.createPublisher(topic);

// 6: Create a text message, and publish it
TextMessage msg = session.createTextMessage();
msg.setText("This is a test message.");
publisher.publish(msg);
}
}--

相關文章