EJB3.0异常总结--- Need to specify class name in environment or system property,

本文详细解释了在使用EJB客户端时遇到的异常‘Need to specify class name in environment or system property’的解决方法。通过在JNDI配置文件中正确设置属性,尤其是使用InitialContext进行上下文初始化时,确保使用java:前缀来指定命名空间,最终成功解决了EJB查找问题。
部署运行你感兴趣的模型镜像
异常:
Need to specify class name in environment or system property, or


as an applet parameter, or in an application resource file:


java.naming.factory.initial
原因:
1.没有写入jndi.properties.
2.Need to specify class name in environment or system property. 的
意思就是找不到你的EJB环境变量. 换句话说就是你的客户在使用lookup
的时候. context没有设置对.
3.Need to specify class name in environment or system property, or
as an applet parameter, or in an application resource file:
java.naming.factory.initial
使用的是代码InitialContext
ctx=new InitialContext(props);的方式,不存在jndi配置文件不对的问
题,最后想起之前一个教程里的一句命名空间的话,于是登录jboss控制
台,找到部署的ejb,前面一个java提醒鸟我,将代码里lookup中参数前
面加上java:,搞定。

public class EjbClient {
public static void main(String[] args) {
Properties props=new Properties();
props.setProperty


("java.naming.factroy.initial","org.jnp.interfaces.NamingContextFact


ory");
props.setProperty


("java.naming.provider.url","localhost:1099");//或者


jnp://localhost...也可
props.setProperty("java.naming.factory.url.pkgs",


"org.jboss.naming:org.jnp.interfaces");//此行必须有
try{
InitialContext ctx=new InitialContext(props);
HelloWorld helloworld=(HelloWorld)ctx.lookup


("java:HelloWorldBean/remote");//前面的java是关键
System.out.println(helloworld.sayHello("jack"));
}catch(NamingException e){
System.out.println("error:"+e.getMessage());
}
}
}

您可能感兴趣的与本文相关的镜像

Llama Factory

Llama Factory

模型微调
LLama-Factory

LLaMA Factory 是一个简单易用且高效的大型语言模型(Large Language Model)训练与微调平台。通过 LLaMA Factory,可以在无需编写任何代码的前提下,在本地完成上百种预训练模型的微调

Unable to bind Business Interface to the JNDI name: LkmNcEjbsLkmOrdersEjb_jarOrderEjb_Home, throw exception javax.naming.NameAlreadyBoundException: [EJB:011224]Unable to bind the interface com.lkm.ejb.orders.remote.OrderRemote to OrderRemote. Another EJB has already bound an interface to that name.; remaining name 'OrderRemote#com/lkm/ejb/orders/remote'. NestedException Message is :[EJB:011224]Unable to bind the interface com.lkm.ejb.orders.remote.OrderRemote to OrderRemote. Another EJB has already bound an interface to that name. [wldeploy] [wldeploy] [wldeploy] [wldeploy] at weblogic.deploy.api.tools.deployer.Jsr88Operation.report(Jsr88Operation.java:610) [wldeploy] at weblogic.deploy.api.tools.deployer.Deployer.perform(Deployer.java:140) [wldeploy] at weblogic.deploy.api.tools.deployer.Deployer.runBody(Deployer.java:88) [wldeploy] at weblogic.utils.compiler.Tool.run(Tool.java:159) [wldeploy] at weblogic.utils.compiler.Tool.run(Tool.java:116) [wldeploy] at weblogic.Deployer.run(Deployer.java:74) [wldeploy] at weblogic.Deployer.mainWithExceptions(Deployer.java:63) [wldeploy] at weblogic.ant.taskdefs.management.DeployerWrapper.main(DeployerWrapper.java:14) [wldeploy] Exception in thread "main" weblogic.Deployer$DeployerException: weblogic.deploy.api.tools.deployer.DeployerException: Task 121 failed: [Deployer:149026]deploy application LkmNcEjbs on MS1. [wldeploy] Target state: redeploy failed on Server MS1 [wldeploy] Unable to bind Business Interface to the JNDI name: LkmNcEjbsLkmOrdersEjb_jarOrderEjb_Home, throw exception javax.naming.NameAlreadyBoundException: [EJB:011224]Unable to bind the interface com.lkm.ejb.orders.remote.OrderRemote to OrderRemote. Another EJB has already bound an interface to that name.; remaining name 'OrderRemote#com/lkm/ejb/orders/remote'. NestedException Message is :[EJB:011224]Unable to bind the interface com.lkm.ejb.orders.remote.OrderRemote to OrderRemote. Another EJB has already bound an interface to that name. [wldeploy] [wldeploy] Task 121 failed: [Deployer:149026]deploy application LkmNcEjbs on MS1. [wldeploy] Target state: redeploy failed on Server MS1 [wldeploy] [wldeploy] [wldeploy] at weblogic.Deployer.run(Deployer.java:76) [wldeploy] at weblogic.Deployer.mainWithExceptions(Deployer.java:63)Unable to bind Business Interface to the JNDI name: LkmNcEjbsLkmOrdersEjb_jarOrderEjb_Home, throw exception javax.naming.NameAlreadyBoundException: [EJB:011224]Unable to bind the interface com.lkm.ejb.orders.remote.OrderRemote to OrderRemote. Another EJB has already bound an interface to that name.; remaining name 'OrderRemote#com/lkm/ejb/orders/remote'. NestedException Message is :[EJB:011224]Unable to bind the interface com.lkm.ejb.orders.remote.OrderRemote to OrderRemote. Another EJB has already bound an interface to that name. [wldeploy] [wldeploy] [wldeploy] [wldeploy] at weblogic.ant.taskdefs.management.DeployerWrapper.main(DeployerWrapper.java:14) [wldeploy] Caused by: weblogic.deploy.api.tools.deployer.DeployerException: Task 121 failed: [Deployer:149026]deploy application LkmNcEjbs on MS1. [wldeploy] Target state: redeploy failed on Server MS1 [wldeploy] Unable to bind Business Interface to the JNDI name: LkmNcEjbsLkmOrdersEjb_jarOrderEjb_Home, throw exception javax.naming.NameAlreadyBoundException: [EJB:011224]Unable to bind the interface com.lkm.ejb.orders.remote.OrderRemote to OrderRemote. Another EJB has already bound an interface to that name.; remaining name 'OrderRemote#com/lkm/ejb/orders/remote'. NestedException Message is :[EJB:011224]Unable to bind the interface com.lkm.ejb.orders.remote.OrderRemote to OrderRemote. Another EJB has already bound an interface to that name. [wldeploy] [wldeploy] [wldeploy] [wldeploy] at weblogic.deploy.api.tools.deployer.Jsr88Operation.report(Jsr88Operation.java:610) [wldeploy] at weblogic.deploy.api.tools.deployer.Deployer.perform(Deployer.java:140) [wldeploy] at weblogic.deploy.api.tools.deployer.Deployer.runBody(Deployer.java:88) [wldeploy] at weblogic.utils.compiler.Tool.run(Tool.java:159) [wldeploy] at weblogic.utils.compiler.Tool.run(Tool.java:116) [wldeploy] at weblogic.Deployer.run(Deployer.java:74) [wldeploy] ... 2 more BUILD FAILED /data/upload/domain01/domain01-ncejb.xml:28: webLogic.Deployer execution failed
最新发布
12-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值