我是JMS和Websphere服务器的新手,我正在尝试从我的Java代码中访问配置在Websphere Application server 8上的JMS队列。我无法确切地理解应该为Context.INITIAL_CONTEXT_FACTORY设置什么值。应该是类的完全限定类名还是特定于应用服务器的类的名称?
Hashtable environment = new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
environment.put(Context.PROVIDER_URL, "iiop://localhost:9081");在将Context.INITIAL_CONTEXT_FACTORY的值设置为完全限定的类名(即com.ms.test.Demo )时,我正在接收NoInitialContextException。
我正在使用的密码-
package com.jms.test;
import java.util.Hashtable;
import javax.jms.Queue;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class Demo {
public static void main(String[] args) throws NamingException {
System.out.println("Start.....");
Hashtable environment = new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.jms.test.Demo");
environment.put(Context.PROVIDER_URL, "iiop://localhost:9081");
//String pUrl = System.getProperty(Context.PROVIDER_URL);
//System.out.println("*******"+pUrl+"********");
InitialContext ctx = new InitialContext(environment);
Queue queue = (Queue) ctx.lookup("jms/TestQ111200");
System.out.println("*** Queue is *** "+queue.toString());
}}我已经使用以下链接中给出的步骤在中进行了JMS配置:was.html
发布于 2014-11-12 17:53:16
在连接到WebSphere时,您总是使用以下内容,而不是您自己的类。
environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");需要正确连接到WAS。对于第二个属性,您需要提供引导端口,而不是http。通常是2809,在SystemOut.log中查找以下消息
00000001 NameServerImp A NMSV0018I: Name server available on bootstrap port 2809.您还需要特定的jars来连接到WAS。请参阅用WebSphere应用服务器安装和配置JMS瘦客户端
https://stackoverflow.com/questions/26892729
复制相似问题