加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

如何从容器外部访问Websphere 7.0中定义的JNDI名称空间?

发布时间:2020-12-15 02:32:28 所属栏目:Java 来源:网络整理
导读:我想使用iiop协议从Container的外部查找Websphere aplication Server 7.0上定义的资源,如下所示: (RMI客户端)Test.jar的Java代码: public static void main(String[] args){HashtableObject,Object properties = new HashtableObject,Object();properties.
我想使用iiop协议从Container的外部查找Websphere aplication Server 7.0上定义的资源,如下所示:

(RMI客户端)Test.jar的Java代码:

public static void main(String[] args){
Hashtable<Object,Object> properties = new Hashtable<Object,Object>();
properties.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory"); 
           properties.put(Context.PROVIDER_URL,"iiop://localhost:2809"); 
InitialContext intCt;
try {
       InitialContext initCtx = new InitialContext(properties);
       Object obj = intCt.lookup(JNDI_NAME);
     }catch (NamingException namingE) {
            System.out.println("Naming Exception occurred :");
            namingE.printStackTrace();
        }   
}

要调用Test.jar的Cmmand文件:

set appClassPath=C:WebSphereAppServer7.0deploytoolitppluginscom.ibm.websphere.v7_7.0.1.v20090422_1423wasJarsnaming.jar;C:WebSphereAppServer7.0deploytoolitppluginscom.ibm.websphere.v7_7.0.1.v20090422_1423wasJarsnamingclient.jar;C:WebSphereAppServer7.0properties;C:BatchCommandFilesJobServerTest.jar

C:WebSphereAppServer7.0javajrebinjava -jar -cp "%appClassPath%" C:BatchCommandFilesJobServerTest.jar %Parameters%  

注意:请注意,我在本地machin和bootstrap主机上运行客户端是:localhost,端口是2809.

在运行Test.jar代码形式命令文件时,我收到以下错误:

javax.naming.NoInitialContextException: Failed to create InitialContext using factory specified in hashtable {java.naming.provider.url=iiop://localhost:2809,java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory} [Root exception is java.lang.NullPointerException]
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:243)
    at javax.naming.InitialContext.initializeDefaultInitCtx(InitialContext.java:327)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:357)
    at javax.naming.InitialContext.internalInit(InitialContext.java:295)
    at javax.naming.InitialContext.(InitialContext.java:212)
    at com.uuic.ets.rmi.server.client.Client.main(Client.java:130)
Caused by: java.lang.NullPointerException
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:235)
    ... 5 more

我不知道为什么这段代码无法实例化InitialContext(Hashmap env).此相同的代码在Websphere应用程序服务器版本5.1中运行,但在Websphere应用程序服务器版本7.0中存在问题.

解决方法

不支持使用WAS_HOME / deploytool中的JAR作为类路径.尝试将记录的 EJB thinclient与WAS_HOME / runtimes / com.ibm.ws.ejb.thinclient_7.0.0.jar一起使用.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读