【问题标题】:Deploy EJB in multiple wars to same app server (Glassfish)在多个战争中将 EJB 部署到同一个应用服务器(Glassfish)
【发布时间】:2014-05-30 15:27:56
【问题描述】:

我们有一个 jar 文件,其中包含 JPA 实体 bean 和一个将 EntityManager 作为服务 bean 注入的无状态会话 bean。服务 bean 有这些注解:

@Stateless
@LocalBean
@EJB(name = "java:global/DataService", beanName = "DataService", beanInterface = DataService.class)

因为 Glassfish 可移植上下文名称包含 war 文件名(及其版本号),所以我们使用 @EJB 注释来定义一个与 war 文件名无关的名称。

这个 jar 是一个依赖项/包含在两个单独的 war 文件中。战争文件部署在同一个 Glassfish (3.1.2.2) 服务器中。我们在日志中发现了绑定问题,并认为问题出在类加载器上。我已经尝试寻找如何将 EJB 多次部署到同一个应用服务器,但找不到任何东西。

有人可以提供搜索词或将我指向解释 EJB 类加载的资源,这可能有助于解决上述问题吗?

根据要求,这是一个示例异常,其中 JPA jar 文件包含在名为 DataModelTest 的测试战争/应用程序中:

[#|2014-05-29T10:47:11.880-0600|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=2132;_ThreadName=Thread-6;|WEB0610: [/DataModelTest] failed to unbind namespace    
javax.naming.NameNotFoundException: Cannot find name to unbind    
    at com.sun.enterprise.naming.impl.TransientContext.doUnbind(TransientContext.java:398)    
    at com.sun.enterprise.naming.impl.TransientContext.unbind(TransientContext.java:420)    
    at com.sun.enterprise.naming.impl.TransientContext.unbind(TransientContext.java:424)    
    at com.sun.enterprise.naming.impl.SerialContextProviderImpl.unbind(SerialContextProviderImpl.java:124)    
    at com.sun.enterprise.naming.impl.SerialContext.unbind(SerialContext.java:740)    
    at javax.naming.InitialContext.unbind(InitialContext.java:435)    
    at javax.naming.InitialContext.unbind(InitialContext.java:435)    
    at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.unpublishObject(GlassfishNamingManagerImpl.java:246)    
    at com.sun.enterprise.container.common.impl.ComponentEnvManagerImpl.unbindFromComponentNamespace(ComponentEnvManagerImpl.java:355)    
    at com.sun.enterprise.web.WebModuleContextConfig.unbindFromComponentNamespace(WebModuleContextConfig.java:454)    
    at com.sun.enterprise.web.WebModuleContextConfig.stop(WebModuleContextConfig.java:447)    
    at com.sun.enterprise.web.WebModuleContextConfig.lifecycleEvent(WebModuleContextConfig.java:174)    
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:149)    
    at org.apache.catalina.core.StandardContext.stop(StandardContext.java:5603)    
    at com.sun.enterprise.web.WebModule.stop(WebModule.java:527)    
    at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1049)    
    at com.sun.enterprise.web.WebContainer.unloadWebModule(WebContainer.java:2230)    
    at com.sun.enterprise.web.WebContainer.unloadWebModule(WebContainer.java:2185)    
    at com.sun.enterprise.web.WebApplication.stop(WebApplication.java:159)    
    at org.glassfish.internal.data.EngineRef.stop(EngineRef.java:169)    
    at org.glassfish.internal.data.ModuleInfo.stop(ModuleInfo.java:302)    
    at org.glassfish.internal.data.ApplicationInfo.stop(ApplicationInfo.java:329)    
    at com.sun.enterprise.v3.server.ApplicationLifecycle.unload(ApplicationLifecycle.java:998)    
    at com.sun.enterprise.v3.server.ApplicationLifecycle.disable(ApplicationLifecycle.java:1970)    
    at com.sun.enterprise.v3.server.ApplicationLoaderService.stopApplication(ApplicationLoaderService.java:454)    
    at com.sun.enterprise.v3.server.ApplicationLoaderService.preDestroy(ApplicationLoaderService.java:422)    
    at com.sun.hk2.component.AbstractCreatorInhabitantImpl.dispose(AbstractCreatorInhabitantImpl.java:83)    
    at com.sun.hk2.component.SingletonInhabitant.release(SingletonInhabitant.java:81)    
    at com.sun.hk2.component.EventPublishingInhabitant.release(EventPublishingInhabitant.java:108)    
    at com.sun.hk2.component.LazyInhabitant.release(LazyInhabitant.java:133)    
    at com.sun.enterprise.v3.server.AppServerStartup.stop(AppServerStartup.java:429)    
    at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.stop(GlassFishImpl.java:88)    
    at com.sun.enterprise.glassfish.bootstrap.GlassFishDecorator.stop(GlassFishDecorator.java:68)    
    at com.sun.enterprise.v3.admin.StopServer.doExecute(StopServer.java:70)    
    at com.sun.enterprise.v3.admin.StopDomainCommand.execute(StopDomainCommand.java:95)    
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)    
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.run(CommandRunnerImpl.java:377)    
|#]    

【问题讨论】:

  • 请将异常堆栈跟踪添加到问题中。
  • 您是否真的有任何由此异常引起的问题,还是仅在重新/取消部署时出现在日志文件中?
  • 过去几天我们尝试了很多东西,但没有发现绑定问题(不确定发生了什么变化)。我们在重新加载/重新部署应用程序时遇到了问题,我为此创建了问题 xxx。

标签: jakarta-ee classloader glassfish-3 ejb-3.1


【解决方案1】:

这不应该要求你将你的两个战争重新打包到一个耳朵里,用一个包含 EJB 的 jar 副本吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-13
    • 1970-01-01
    • 2019-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多