Can I place all of my EJB deployment descriptors in the META-INF directory of an EAR file, rather than the EJB jar files

和自甴很熟 提交于 2019-12-11 04:39:46

问题


I have an enterprise application which is delivered as an EAR file. The META-INF folder within the ear contains 'application.xml' as expected, with a list of modules belonging to the application.

There are a number of EJB jar files within the ear also, each of which contain a number of EJBs. For certain reasons, we wish to use XML deployment descriptors to configure all of the ejbs. As a result we have a number of ejb-jar files, each one embedded in the META-INF folder of each jar within the ear file like this.

EAR_FILE
:     
:-----META-INF
:           :
:           -application.xml
:     
:     
:------EJB_JAR_1
:              :
:              -META-INF
:                      :
:                      -ejb-jar.xml
:------EJB_JAR_2
:              :
:              -META-INF
:                      :
:                      -ejb-jar.xml
:------EJB_JAR_3
              :
              -META-INF
                      :
                      -ejb-jar.xml


As you can see, this results in a number of individual ejb-jar.xml deployment descriptors. We would like to be able to centralise this into a single deployment descriptor which defines all ejbs in the application.

also, we want to keep the separate ejb jar files within the ear, rather than having them all in a single ear.

Is it possible to have a 'master' ejb-jar file in the META-INF folder of the ear file which contains the configuration for all EJBs in the application?

Or is it possible even to place the ejb-jar files outside the actual jar containing the EJBs?

At the end of the day, what I'm really looking to achieve is to centralise all of the ejb deployment descriptors into one file somewhere, rather than having them spread over each individual EJB jar as above?

Many thanks,

Dave.


回答1:


Or is it possible even to place the ejb-jar files outside the actual jar containing the EJBs?

Yes, though more accurately: it is possible to have EJB classes outside the EJB module JAR. In other words, you can create a single EJB module with a single ejb-jar.xml, and then put all the EJB_JAR_1, EJB_JAR_2, etc. in the EAR/lib/ directory, which automatically makes all the JARs visible to all the EJB modules in the EAR (or, the singular EJB module in your case). Alternatively, you could manually maintain a Class-Path: ejb-1.jar ejb-2.jar list in the EJB module META-INF/MANIFEST.MF, but that's more work.



来源:https://stackoverflow.com/questions/10552552/can-i-place-all-of-my-ejb-deployment-descriptors-in-the-meta-inf-directory-of-an

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!