我正在使用Websphere自由。 我尝试访问jndiEntry时遇到问题。查找下面的代码未执行/ server.xml:
<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">
<featureManager>
<feature>webProfile-8.0</feature>
<feature>jndi-1.0</feature>
<feature>ejbRemote-3.2</feature>
<feature>localConnector-1.0</feature>
<feature>adminCenter-1.0</feature>
</featureManager>
<httpEndpoint id="defaultHttpEndpoint"
httpPort="9080"
httpsPort="9443" />
<applicationManager autoExpand="true"/>
<jndiEntry jndiName="schoolOfAthens/defaultAdminUserName" value='"plato"' />
<iiopEndpoint iiopPort="2809" id="defaultIiopEndpoint">
<iiopsOptions iiopsPort="2810"></iiopsOptions>
</iiopEndpoint>
<orb nameService="corbaname::localhost:2809" iiopEndpointRef="defaultIiopEndpoint">
</orb>
<remoteFileAccess>
<writeDir>${server.config.dir}</writeDir>
</remoteFileAccess>
<logging consoleLogLevel="INFO" />
</server>
我正在尝试从客户端代码访问jndiEntry:
package com.ibm.test;
import javax.naming.*;
import java.util.*;
public class myTest {
public static void main( String args[]) {
try{
InitialContext ctx = new InitialContext();
Object object = ctx.lookup("schoolOfAthens/defaultAdminUserName");
System.out.println("object: ");
} catch (Exception e){
e.printStackTrace();
}
}
}
当我运行程序时,查找下面的行没有得到执行。
我正在使用以下罐子: 1. ejbRemotePortable.jar 2. com.ibm.ws.ejb.thinclient_9.0.jar 3. com.ibm.ws.orb_9.0.jar