EJB 3.1 application deployed as WAR-only: What about ejb-jar.xml?

后端 未结 2 1084
旧巷少年郎
旧巷少年郎 2021-02-08 22:33

I have a JavaEE6 application, consisting of Web stuff and EJBs and which is deployed as WAR-only (using EJB3.1). The build is based on Maven. I just read about a new possibilit

2条回答
  •  走了就别回头了
    2021-02-08 23:20

    In short, it is not possible with a WAR based deployment.

    The module initialization feature of Java EE 6 is meant for initializing different modules of an application in a specific order. The moment you have a WAR based EJB application, you no longer have separate modules for your EJB and Web application. There is just one module - the web application module in a WAR based deployment.

    Therefore, if you have to achieve the same feature as the module initialization order, offered in Java EE 6, you'll have to do either of the following:

    • Separate the EJB into a separate module, and use a EAR based deployment.
    • This is more or less trickery, as was done in Java EE 5, and you would want to be avoiding it. You might want to code in logic to ensure that the singleton EJBs have been created (assuming that this is due to the use of singletons in your application), before they're utilized in code.

    Location of the ejb-jar.xml in a WAR file

    The EJB 3.1 specification (in the chapter on Packaging) addresses the issue of the location of the ejb-jar.xml file when deployed in a WAR:

    In a .war file, the deployment descriptor is stored with the name WEB-INF/ejb-jar.xml.

    PS: I haven't tried this style of deployment yet. YMMV.

提交回复
热议问题