You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Weblogic 10.3.6升级至12cR2后部署遇NameAlreadyBoundException求助

问题:WebLogic 12cR2部署EJB时遭遇JNDI名称已绑定错误

背景与问题描述

我有一个基于Java 1.6和WebLogic 10.3.6运行的应用,现在要迁移到Java 1.8和WebLogic 12cR2(12.2.1.3)。通过ANT编译代码成功生成了EAR文件,但部署到新版本WebLogic时出现了以下错误:

weblogic.application.ModuleException: Unable to bind Business Interface to the JNDI name: myapp_admin_ejb_jarAdminServiceBean_Home, throw exception javax.naming.NameAlreadyBoundException: [EJB:011224]Unable to bind the interface com.abc.xyz.admin.ejb.session.AdminServiceRemote to remote. Another EJB has already bound an interface to that name.; remaining name 'ejb/admin_service_jndi'. NestedException Message is : Unable to bind the interface to remote. Another EJB has already bound an interface to that name. at weblogic.application.internal.ExtensibleModuleWrapper.activate(ExtensibleModuleWrapper.java:123) <May 29, 2018 3:56:04,460 PM IST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "10661298941920" for task "0" on [partition-name: DOMAIN]. Error is: "weblogic.application.ModuleException: Unable to bind Business Interface to the JNDI name: myapp_admin_ejb_jarAdminServiceBean_Home, throw exception javax.naming.NameAlreadyBoundException: [EJB:011224]Unable to bind the interface com.abc.xyzadmin.ejb.session.AdminServiceRemote to remote. Another EJB has already bound an interface to that name.; remaining name 'ejb/admin_service_jndi'. NestedException Message is :[EJB:011224]Unable to bind the interface com.abc.xyzadmin.ejb.session.AdminServiceRemote to remote. Another EJB has already bound an interface to that name." weblogic.application.ModuleException: Unable to bind Business Interface to the JNDI name: myapp_admin_ejb_jarAdminServiceBean_Home, throw exception javax.naming.NameAlreadyBoundException: [EJB:011224]Unable to bind the interface com.abc.xyzadmin.ejb.session.AdminServiceRemote to remote. Another EJB has already bound an interface to that name.; remaining name 'ejb/admin_service_jndi'. NestedException Message is :[EJB:011224]Unable to bind the interface com.abc.xyzadmin.ejb.session.AdminServiceRemote to remote. Another EJB has already bound an interface to that name. at weblogic.application.internal.ExtensibleModuleWrapper.activate(ExtensibleModuleWrapper.java:123) at weblogic.application.internal.flow.ModuleListenerInvoker.activate(ModuleListenerInvoker.java:114) at weblogic.application.internal.flow.ModuleStateDriver$2.next(ModuleStateDriver.java:212) at weblogic.application.internal.flow.ModuleStateDriver$2.next(ModuleStateDriver.java:207) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45) Truncated. see log file for complete stacktrace Caused By: Unable to bind Business Interface to the JNDI name: myapp_admin_ejb_jarAdminServiceBean_Home, throw exception javax.naming.NameAlreadyBoundException: [EJB:011224]Unable to bind the interface com.abc.xyzadmin.ejb.session.AdminServiceRemote to remote. Another EJB has already bound an interface to that name.; remaining name 'ejb/admin_service_jndi'. NestedException Message is :[EJB:011224]Unable to bind the interface com.abc.xyzadmin.ejb.session.AdminServiceRemote to remote. Another EJB has already bound an interface to that name. at weblogic.ejb.container.deployer.Ejb3SessionBinder.bindToJNDI(Ejb3SessionBinder.java:144) at weblogic.ejb.container.deployer.ClientDrivenBeanInfoImpl.activate(ClientDrivenBeanInfoImpl.java:900) at weblogic.ejb.container.deployer.EJBDeployer.activate(EJBDeployer.java:770) at weblogic.ejb.container.deployer.EJBModule.activate(EJBModule.java:447) at weblogic.application.internal.ExtensibleModuleWrapper$ActivateStateChange.next(ExtensibleModuleWrapper.java:317) Truncated. see log file for complete stacktrace

我已经检查了代码,没有发现重复的EJB JNDI引用,weblogic.xml、weblogic-ejb-jar.xml等配置文件也都正常。本地同时运行着新旧版本的WebLogic服务器,旧版本Java 6的代码运行正常,重新部署也没问题。我也升级了项目类路径中所需的所有JAR文件,使用的是WebLogic 12cR2自带的JAR,请问迁移过程中还遗漏了什么?


解决思路与方案

结合我处理过的类似WebLogic迁移案例,以及12cR2对EJB JNDI绑定的行为变化,给你几个具体的排查方向:

1. 显式指定EJB的JNDI绑定名称

WebLogic 12c对EJB的默认JNDI绑定规则做了调整,尤其是EJB 3.x的远程接口。在10.3.6中,远程接口可能仅用接口类名绑定,但12c会结合EJB名称、模块名生成更复杂的默认名称,容易和其他同接口的EJB冲突。

你可以在weblogic-ejb-jar.xml里给目标EJB显式指定远程JNDI名称,绕过默认规则:

<weblogic-ejb-jar xmlns="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar" version="1.2">
  <weblogic-enterprise-bean>
    <ejb-name>AdminServiceBean</ejb-name>
    <remote-jndi-name>ejb/admin_service_jndi</remote-jndi-name>
  </weblogic-enterprise-bean>
</weblogic-ejb-jar>

2. 检查EAR包中的重复类或EJB定义

虽然你自查了代码,但ANT编译时可能不小心把旧版本的类或者重复的EJB类打包进了EAR。建议:

  • 解压生成的EAR,检查对应的EJB模块(比如admin-ejb.jar)里有没有重复的AdminServiceRemote接口类,或者混入了其他模块的同名类。
  • 确认项目依赖里没有同时引入新旧版本的EJB模块JAR,比如类路径里是不是既有新的admin-ejb.jar又有旧的。

3. 清理WebLogic域的缓存与残留部署

WebLogic 12c的部署缓存比10g更“顽固”,旧部署的残留可能导致JNDI绑定冲突。试试:

  • 先停掉WebLogic服务器,删除域目录下的tmp、cache,还有servers/[你的服务器名]/tmp这些缓存目录。
  • 重启服务器后,先卸载所有相关的旧应用,再重新部署新的EAR包。
  • 如果用了分区(Partition),还要确认分区里没有残留的旧应用部署。

4. 验证EJB注解的兼容性

如果你的EJB用了EJB 3.x注解(比如@Remote、@Stateless),12c对注解的解析更严格:

  • 检查AdminServiceBean的@Remote注解是不是指定了正确的接口,有没有重复的@Remote声明:
@Stateless(name = "AdminServiceBean")
@Remote(AdminServiceRemote.class)
public class AdminServiceBean implements AdminServiceRemote {
  // 业务逻辑
}
  • 确保没有多个EJB类使用同一个@Remote接口却没指定不同的JNDI名称。

5. 检查部署时的WebLogic参数

WebLogic 12c新增了一些部署选项,比如“Deploy as a library”或者“Application scoping”,这些会影响JNDI名称的作用域。部署时要选独立应用部署,不要作为库部署,同时确认应用的JNDI作用域是全局唯一的。


内容的提问来源于stack exchange,提问作者Som

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:19:13