关于jbuilder5和weblogic6.1联合开发ejb的问题。

The_east_key 2002-04-01 10:46:25
大家好,我在用jbuilder开发ejb的时候,根据http://www.yesky.com/20020116/214231.shtml做了,现在用客户测试的时候,总是出现一些问题,请指教;
------------------------------------------------------------------------
代码如下:
package quickstart;
import javax.naming.*;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;
public class Client {
private TellerHome tellerHome = null;
//*************************************************************
// Client client = new Client();
//*************************************************************

/**Construct the EJB test client*/
public Client() {
try {
//get naming context
Context ctx = getInitialContext();
//look up jndi name
Object ref = ctx.lookup("TellerHome");
//cast to Home interface
tellerHome = (TellerHome) PortableRemoteObject.narrow(ref, TellerHome.class);
Teller teller=tellerHome.create();
String str=teller.getDefaultStr();
System.out.println(str);
}
catch(Exception e) {
e.printStackTrace();
}
}
private Context getInitialContext() throws Exception {
String url = "t3://localhost: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) {
System.out.println("Unable to connect to WebLogic server at " + url);
System.out.println("Please make sure that the server is running.");
throw e;
}
}

//----------------------------------------------------------------------------
// Utility Methods
//----------------------------------------------------------------------------

public TellerHome getHome() {
return tellerHome;
}
/**Main method*/

public static void main(String[] args) {
Client client = new Client();
// Use the getHome() method of the client object to call Home interface
// methods that will return a Remote interface reference. Then
// use that Remote interface reference to access the EJB.
}
}

----------------------------------------------------------------------
问题1:
请注意
//*************************************************************
// Client client = new Client();
//*************************************************************
当此行被注释掉的时候,出现如下错误:
javax.naming.NameNotFoundException: Unable to resolve TellerHome. Resolved: '' Unresolved:'TellerHome' ; remaining name ''
当此行有效的时候:
ava.lang.StackOverflowError
at quickstart.Client.<init>(Client.java:9)
at quickstart.Client.<init>(Client.java:9)
现在我已经试了很多次了,还是不能成功,谢谢大家指教。

...全文
54 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
zwhhwz 2002-04-10
  • 打赏
  • 举报
回复
你的EJB应该是没有DEPLOY成功,重新DEPLOY一下,选择REDEPLOY
鹏源雪峰 2002-04-10
  • 打赏
  • 举报
回复
我在jbuild6也看过一次这样的问题,但代码不可能有错的,所以真的很奇怪的
The_east_key 2002-04-10
  • 打赏
  • 举报
回复
已经发布上去了 。所以很奇怪。
uu_snow 2002-04-10
  • 打赏
  • 举报
回复
你的EJB发布过吗?
The_east_key 2002-04-08
  • 打赏
  • 举报
回复
--------------------------------------------------------------
TellerHome.java的原代码:
package quickstart;

import java.rmi.*;
import javax.ejb.*;

public interface TellerHome extends EJBHome {
public Teller create() throws RemoteException, CreateException;
}
********************************************************************
TellerBean.java的原代码:
package quickstart;

import java.rmi.*;
import javax.ejb.*;

public class TellerBean implements SessionBean {
private SessionContext sessionContext;
public void ejbCreate() {
}
public void ejbRemove() throws RemoteException {
}
public void ejbActivate() throws RemoteException {
}
public void ejbPassivate() throws RemoteException {
}
public void setSessionContext(SessionContext sessionContext) throws RemoteException {
this.sessionContext = sessionContext;
}

public String getDefaultStr()
{
return "Hello,this is a examples made by sunxiaoming!";
}
}
**************************************************************
Teller.java
package quickstart;

import java.rmi.*;
import javax.ejb.*;

public interface Teller extends EJBObject {
public java.lang.String getDefaultStr() throws RemoteException;
}
****************************************************************
Client.java
package quickstart;

import javax.naming.*;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;
import quickstart.TellerBean;


public class Client {
private TellerHome tellerHome = null;
// Client client = new Client();
/**Construct the EJB test client*/
public Client() {
try {
//get naming context
Context ctx = getInitialContext();
//look up jndi name
Object ref = ctx.lookup("TellerHome");
//cast to Home interface
tellerHome = (TellerHome) PortableRemoteObject.narrow(ref, TellerHome.class);
// Teller teller=tellerHome.create();
// String str=teller.getDefaultStr();
// System.out.println(str);
}
catch(Exception e) {
e.printStackTrace();
}
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private Context getInitialContext() throws Exception {
String url = "t3://localhost: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) {
System.out.println("Unable to connect to WebLogic server at " + url);
System.out.println("Please make sure that the server is running.");
throw e;
}
}
//----------------------------------------------------------------------------
// Utility Methods
//----------------------------------------------------------------------------
public TellerHome getHome() {
return tellerHome;
}
/**Main method*/
public static void main(String[] args) {
Client client = new Client();
// Use the getHome() method of the client object to call Home interface
// methods that will return a Remote interface reference. Then
// use that Remote interface reference to access the EJB.
}
private void jbInit() throws Exception {
}
}
****************************************************************

biosun 2002-04-04
  • 打赏
  • 举报
回复
我出遇到同样的问题!但好像同样的EJB在Jbuilder5.0+WebLogic6.1下就不会出现这样的问题。
merry_xin 2002-04-03
  • 打赏
  • 举报
回复
把ejb的所有代码,加上来,我看看。
The_east_key 2002-04-03
  • 打赏
  • 举报
回复
还是不行,我应该怎么做?Please help me!
zhipop 2002-04-01
  • 打赏
  • 举报
回复
没有把这个TellerHome类包含进去,所以不能调用方法

看看是不是,应该 import TellerHome;
zhipop 2002-04-01
  • 打赏
  • 举报
回复
看问题好象TellerHome出什么问题了
其他应该没有什么问题,你实例化的时候好象出问题的
zhiweihua 2002-04-01
  • 打赏
  • 举报
回复
EJB发布成功了吗?

1,233

社区成员

发帖
与我相关
我的任务
社区描述
企业软件 中间件技术
社区管理员
  • 中间件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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