为什么找不到jms连接工厂?
井中老男孩 2003-07-21 10:38:53 我写了一个消息bean.
并且我在weblogic7中已经配置了MyConnectionFactory(jndi名)
我写了个客户端发送消息,提示我:
javax.naming.NameNotFoundException: Unable to resolve 'MyConnectionFactory' Resolved: '' Unresolved:'MyConnectionFactory' ; remaining name 'MyConnectionFactory'
客户端代码:
package wks;
import javax.naming.*;
import javax.jms.*;
public class test {
public test() {
}
public static void main(String[] args) throws Exception
{
QueueConnection qConnection;
QueueSession qSession;
QueueSender qSender;
Queue queue;
Context context=new InitialContext();
QueueConnectionFactory queueFactory=(QueueConnectionFactory)context.lookup("MyConnectionFactory");
qConnection=queueFactory.createQueueConnection();
qSession=qConnection.createQueueSession(true,Session.AUTO_ACKNOWLEDGE);
queue=(Queue)context.lookup("MyJMSQueue");
qSender=qSession.createSender(queue);
TextMessage a=qSession.createTextMessage("我是王昆山");
qSender.send(a);
a=qSession.createTextMessage();
qSender.send(a);
qSender.close();
qSession.close();
qConnection.close();
}
}
jndi.properties文件内容:
java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
java.naming.provider.url=t3://wksxp:7001