Jbuilder8+weblogic7+oracle9i下EJB的BMP客户端测试的问题!

singlehuang 2003-08-22 07:33:32
急!!!!!我按<<CSDN_文档中心_Jbuilder8开发J2ee学习笔记>>做一个BMP的例子,部署完后,用Jbuilder中的标准客户端测试时,出现这样的错误:javax.naming.CommunicationException. Root exception is java.net.ConnectException: t3://billgates:7001: Destination unreachable; nested exception is:
java.net.ConnectException: Connection refused: connect; No available router to destination
......


客户端的类名为BMPBEANTestClient.java,以下是部分代码:

private BMPBEANHome bMPBEANHome = null;
private BMPBEAN bMPBEAN = null;

public BMPBEANTestClient() {
initialize();
}

public void initialize() {
long startTime = 0;
if (logging) {
log("Initializing bean access.");
startTime = System.currentTimeMillis();
}

try {
Context context = getInitialContext();
//look up jndi name
Object ref = context.lookup("BMPBEANRemote");
//look up jndi name and cast to Home interface
bMPBEANHome = (BMPBEANHome) PortableRemoteObject.narrow(ref, BMPBEANHome.class);
if (logging) {
long endTime = System.currentTimeMillis();
log("Succeeded initializing local bean access through Local Home interface.");
log("Execution time: " + (endTime - startTime) + " ms.");
}
}
catch(Exception e) {
if (logging) {
log("Failed initializing bean access.");
}
e.printStackTrace();
}
}

private Context getInitialContext() throws Exception {
//是不是这里错了呢????
String url = "t3://billgates:7001";
String user = null;
String password = null;
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);
}

return new InitialContext(properties);
}
catch(Exception e) {
log("Unable to connect to WebLogic server at " + url);
log("Please make sure that the server is running.");
throw e;
}
}

...全文
30 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
singlehuang 2003-08-23
  • 打赏
  • 举报
回复
问题解决了,String url = "t3://billgates:7001";
改为String url = "t3://localhost:7001";
我是新手,我也不知道配置时在哪里把billgates改为localhost,哪位高手可以告诉我!!
hpq852 2003-08-22
  • 打赏
  • 举报
回复
测试不需要这么麻烦,简单就是美:把多余的部分都去掉 象:
public BMPBEANTestClient() {
initialize();
}

public void initialize() {
long startTime = 0;
if (logging) {
log("Initializing bean access.");
startTime = System.currentTimeMillis();
}

if (user != null) {
properties.put(Context.SECURITY_PRINCIPAL, user);
properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
}

留下关键部分在测试一下。

Sundery 2003-08-22
  • 打赏
  • 举报
回复
我有仔细看了看:String user = null;

然后后面就是有: if (user != null)

晕倒了,这明显不可能吧?

应该有user = request.getSession().setAttribute("user")之类的嘛?

需要例子的话,我们老大zez有一套的,晚上他不在,你要的话,发消息给我好了留email地址
Sundery 2003-08-22
  • 打赏
  • 举报
回复
properties.put(Context.PROVIDER_URL, url);
以及相应的url去掉,再试试看:)

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧