简体   繁体   English

Glassfish:为什么同一个MDB有两个池:一个在ejb中,一个在战争中?

[英]Glassfish: Why are there 2 pools for the same MDB: one in ejb and one in war?

SCENARIO: 场景:

I have a java maven ear project that I run on GF 3.1.2. 我有一个在GF 3.1.2上运行的java maven ear项目。 In that project I want to use a MDB defined in an individual ejb module so i put it as a dependency. 在该项目中,我想使用在单个ejb模块中定义的MDB,因此我将其作为依赖项。 So the structure is as follows: 所以结构如下:

ProjectEAR:
   - ProjectEJB
        - ProjectWithProblematicMDB
   - ProjectWAR
        - dependency ProjectEJB with scope provided

ACTUAL PROBLEM: 实际问题:

When this is deployed to glassfish, with the help of jconsole, i see two different MDB pools for the ProblematicMDB: one in the ejb module and one in the war module. 当在jconsole的帮助下将其部署到glassfish时,我看到了ProblematicMDB的两个不同的MDB池:一个在ejb模块中,一个在war模块中。 They are not the same pool since I have set the deployment descriptor on ProjectEJB to limit the pool size to 1 and the pool's size in ProjectEJB doesn't get larger than one but the one in ProjectWAR grows in size. 它们不是同一个池,因为我已经在ProjectEJB上设置了部署描述符以将池的大小限制为1,并且ProjectEJB中的池的大小不会大于1,但是ProjectWAR中的池的大小会增加。

This happens with all MDBS=s from modules referred in ProjectEJB as dependencies, but does not happen with the "native" MDBs from ProjectEJB. 对于ProjectEJB中称为依赖项的模块中的所有MDBS =,这会发生,而对于ProjectEJB中的“本地” MDB,则不会发生这种情况。 I must mention the fact that I cannot exclude ProjectWithProblematicMDB from the war since I am using some beans there (not the mdb) . 我必须提到一个事实,就是我不能从战争中排除ProjectWithProblematicMDB,因为我在那里使用了一些bean(而不是mdb)。

THE QUESTION(S): 问题:

Why are there two pools for the same MDB? 为什么同一MDB有两个池? How can I have only one pool in this scenario? 在这种情况下,如何只有一个池?

I finally found the reason and the solution. 我终于找到了原因和解决方案。

REASON: 原因:

Looking into the .ear archive I saw that the "native" ejb (ProjectEJB) was placed into the root of the archive and the "independent" ejb (ProjectWithProblematicMDB) was packed in the lib folder. 查看.ear档案,我看到“本机” ejb(ProjectEJB)被放置在档案的根目录中,而“独立” ejb(ProjectWithProblematicMDB)被包装在lib文件夹中。 For some reason because of this, glassfish was creating the pool in the .war module too. 由于某些原因,glassfish也在.war模块中创建了池。

SOLUTION: 解:

Adding ProjectWithProblematicMDB to ProjectEAR as a dependecy made maven pack it in the root of the .ear archive too and wasn't in the lib folder anymore. 将ProjectWithProblematicMDB作为依赖项添加到ProjectEAR中,使Maven还将其打包到.ear归档文件的根目录中,并且不再位于lib文件夹中。 After I deployed the application in this form, the second pool (the one from the .war) was not created anymore. 以这种形式部署应用程序后,不再创建第二个池(来自.war的池)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM