请问在客户端直接用jndi名称访问本地ejb,而不用引用,怎么写?
AccountLocal local = null;
Properties env = new Properties();
env.setProperty(Context.PROVIDER_URL, "iiop://localhost:2809");
env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
try {
Context ctx = new InitialContext(env);
AccountLocalHome home = (AccountLocalHome) PortableRemoteObject.narrow(
ctx.lookup("AccountLocalHome"),AccountLocalHome.class);
local = home.create("001","wanglaowu");
//local.deposit(5000);
} catch (Exception e) {
e.printStackTrace();
}
其中:本地ejb的jndi名称就是:AccountLocalHome
出现这个错
javax.naming.NameNotFoundException: Context: localhost/nodes/localhost/servers/server1, name: AccountLocalHome: First component in name AccountLocalHome not found. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:84)
at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(Unknown Source)
at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve(CNContextImpl.java:3491)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1519)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1480)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1187)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1067)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:132)
at javax.naming.InitialContext.lookup(InitialContext.java:360)
at hiltonlee.entity.client.AccountClient.main(AccountClient.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
at java.lang.reflect.Method.invoke(Method.java:386)
at com.ibm.websphere.client.applicationclient.launchClient.createContainerAndLaunchApp(launchClient.java:627)
at com.ibm.websphere.client.applicationclient.launchClient.main(launchClient.java:422)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
at java.lang.reflect.Method.invoke(Method.java:386)
at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:105)
问题点数:0、回复次数:0Top




