weblogic7+jbuiler7初学者bean互相调用问题求教(在线求教)
u_u_u 2002-11-11 04:52:16 我的环境是weblogic7+jbuiler7,调用的次序如下:
client->session bean->entity bean->db
问题处在session bean->entity bean环节,
主体代码如下(省略了系统自动生成的代码,编译发布成功):
import cmpdemo.*;
public class HelloBean2Bean implements SessionBean {
public java.lang.String SayHello()
{
try
{
Tab01 tab = getTab01Home().findByPrimaryKey("abcdefg");
return new String(tab.getName());
}
catch(Exception e) { throw new EJBException(e); }
}
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) {
throw e;
}
}
private Tab01Home getTab01Home()
{
InitialContext initCtx = null;
try
{
Context ctx = getInitialContext();
Object ref = ctx.lookup("Tab01");
return (Tab01Home)ref;
}
catch(Exception e) { throw new EJBException( e); }
}
}
客户端代码为自动生成代码执行时出错(entity bean Tab01单独用自动生成客户端测试没有问题),信息如下:
E:\bea\jdk131_03\bin\javaw -classpath "D:\Dep\J2EE\EJB\jbproject\HelloDemo2\classes;E:\bea\weblogic700\server\lib\weblogic_sp.jar;E:\bea\weblogic700\server\lib\weblogic.jar;D:\Dep\J2EE\EJB\jbproject\CMPDemo\classes;E:\bea\jdk131_03\jre\lib\i18n.jar;E:\bea\jdk131_03\jre\lib\jaws.jar;E:\bea\jdk131_03\jre\lib\rt.jar;E:\bea\jdk131_03\jre\lib\sunrsasign.jar;E:\bea\jdk131_03\lib\dt.jar;E:\bea\jdk131_03\lib\htmlconverter.jar;E:\bea\jdk131_03\lib\tools.jar" hellodemo2.HelloBean2TestClient1
-- Initializing bean access.
-- Succeeded initializing bean access.
-- Execution time: 4484 ms.
-- Calling create()
-- Succeeded: create()
-- Execution time: 47 ms.
-- Return value from create(): hellodemo2.HelloBean2Bean_6xtxps_EOImpl_WLStub@2cb585.
-- Calling SayHello()
java.rmi.RemoteException: EJB Exception: ; nested exception is:
javax.ejb.EJBException: nested exception is: javax.ejb.EJBException: nested exception is: javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'app/ejb/CMPMoudle.jar#Tab01/local-home' Resolved: 'app/ejb' Unresolved:'CMPMoudle.jar#Tab01' ; remaining name 'CMPMoudle.jar#Tab01/local-home']; Link Remaining Name: 'java:app/ejb/CMPMoudle.jar#Tab01/local-home'
Start server side stack trace:
java.rmi.RemoteException: EJB Exception: ; nested exception is:
javax.ejb.EJBException: nested exception is: javax.ejb.EJBException: nested exception is: javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'app/ejb/CMPMoudle.jar#Tab01/local-home' Resolved: 'app/ejb' Unresolved:'CMPMoudle.jar#Tab01' ; remaining name 'CMPMoudle.jar#Tab01/local-home']; Link Remaining Name: 'java:app/ejb/CMPMoudle.jar#Tab01/local-home'
。。。。省略