将多个战争中的EJB部署到同一个应用服务器(Glassfish)

时间:2014-05-30 15:27:57

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

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

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

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

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

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

根据要求,这是一个示例异常,其中JPA jar文件包含在名为DataModelTest的测试war / app中:

[#|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)    
|#]    

1 个答案:

答案 0 :(得分:0)

难道这不需要你将你的两场战争重新打包到一个耳中,只有一个包含EJB的jar副本吗?