一个Sessionless BEAN

02-12-31 梦娇

我用EJB2。0做了一个SESSIONLESS BEAN ,然后做了他的测试客户断

客户断如下:

package entpro;

import javax.naming.Context;

import javax.naming.InitialContext;

import javax.naming.NamingException;

import javax.rmi.PortableRemoteObject;

import java.util.Properties;

import javax.rmi.*;

public class MyClient {

public MyClient() {

try{

Properties p=new Properties();

p.put(Context.INITIAL_CONTEXT_FACTORY ,"weblogic.jndi.WLInitialContextFactory") ;

p.put(Context.PROVIDER_URL ,"t3://localhost:7001");

Context con=new InitialContext(p);

Object ob=con.lookup("entpro.GoodsHome") ;

GoodsHome home=(GoodsHome)PortableRemoteObject.narrow(ob,GoodsHome.class) ;

Goods goods= home.create() ;

goods.buy("book",13) ;

goods.getRemain() ;

}

catch(Exception ex){

System.out.print(ex.getMessage()+"我的异常!!!") ;

}

}

public static void main(String[] args) {

MyClient myClient1 = new MyClient();

}

}

编译通过,但运行时提示如下:(JB7)

D:\bea\jdk131_03\bin\javaw -classpath "C:\mypro\EntPro\classes;D:\bea\weblogic700\server\lib\weblogic_sp.jar;D:\bea\weblogic700\server\lib\weblogic.jar;D:\bea\jdk131_03\bin\MyModule.jar;D:\bea\jdk131_03\jre\lib\i18n.jar;D:\bea\jdk131_03\jre\lib\jaws.jar;D:\bea\jdk131_03\jre\lib\rt.jar;D:\bea\jdk131_03\jre\lib\sunrsasign.jar;D:\bea\jdk131_03\lib\dt.jar;D:\bea\jdk131_03\lib\htmlconverter.jar;D:\bea\jdk131_03\lib\tools.jar" entpro.MyClient

Unable to resolve 'entpro.GoodsHome' Resolved: '' Unresolved:'entpro'

该Bean 已被成功部署到Weblogic7上,其ejb-jar.xml的 home元素有HOME接口名\<home\>entpro.GoodsHome\</home\>

哪位大哥哥能帮忙解决一下吗?

banq
2003-01-02 11:00

除了ejb-jar.xml必须配置外,还有weblogic自己的配置文件.xml也要配置