可能是你的代码没有正确使用:
import javax.naming.*;
import javax.rmi.PortableRemoteObject;String message = "failed";
Context context = null;
try {
//get naming context
String url = "t3://localhost:7001";
String user = "username";
String password = "password";
Properties properties = null;
try {
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
if (user != null) {
properties.put(Context.SECURITY_PRINCIPAL, user);
properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
} context = new InitialContext(properties);
}
catch(Exception e) {
System.out .println(" Unable to connect to WebLogic server at " + url);
System.out .println("Please make sure that the server is running."); }
//look up jndi name
Object ref = context.lookup("ClientSession");
....
....
import javax.naming.*;
import javax.rmi.PortableRemoteObject;String message = "failed";
Context context = null;
try {
//get naming context
String url = "t3://localhost:7001";
String user = "username";
String password = "password";
Properties properties = null;
try {
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
if (user != null) {
properties.put(Context.SECURITY_PRINCIPAL, user);
properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
} context = new InitialContext(properties);
}
catch(Exception e) {
System.out .println(" Unable to connect to WebLogic server at " + url);
System.out .println("Please make sure that the server is running."); }
//look up jndi name
Object ref = context.lookup("ClientSession");
....
....
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货