部署为WAR-only的EJB 3.1应用程序:ejb-jar.xml怎么样? [英] EJB 3.1 application deployed as WAR-only: What about ejb-jar.xml?

查看:206
本文介绍了部署为WAR-only的EJB 3.1应用程序:ejb-jar.xml怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JavaEE6应用程序,由Web资源和EJB组成,并且部署为仅使用WAR(使用EJB3.1)。构建基于Maven。我刚刚读到了在Java EE 6中订购模块初始化的新可能性此处这也是我的申请所需要的。此外,我希望有一个选项来定义XML中的一些EJB属性。



由于该示例是作为EAR项目部署的,因此订单在应用程序中定义。 XML。但是在WAR部署的项目中,没有application.xml。现在我想知道我在哪里可以定义这样的信息?或者是否可以在WAR-deployed-app中以某种方式使用application.xml?



编辑:



哎呀我没有正确读取模块顺序示例,在第一时间我认为它是关于我的应用程序中的EJB加载的顺序。当然我的WAR-app中只有一个模块,所以排序没有意义。



好的,但是正如我所说,还有一个大问题(也改变了问题标题以反映变化):ejb-jar.xml怎么样?我能用某种方式在XML中定义关于我的EJB的东西(因为它对某些设置有用,以避免重新编译)?

解决方案

简而言之,基于WAR的部署是不可能的。



Java EE 6的模块初始化功能用于按特定顺序初始化应用程序的不同模块。拥有基于WAR的EJB应用程序的那一刻,您不再拥有EJB和Web应用程序的单独模块。在基于WAR的部署中只有一个模块 - Web应用程序模块



因此,如果必须实现与在Java EE 6中提供的模块初始化顺序,您必须执行以下任一操作:




  • 将EJB分离到单独的模块中,并使用基于EAR的部署。

  • 这或多或少都是骗局,就像在Java EE 5中所做的那样,你可能希望避免它。您可能希望在逻辑中进行编码以确保在代码中使用单个EJB之前(假设这是由于在您的应用程序中使用单例),



  • ejb-jar.xml在WAR文件中的位置



    EJB 3.1规范(在打包一章中)解决了位置问题部署在WAR中的ejb-jar.xml文件:


    在.war文件中,存储部署
    描述符名称为
    WEB-INF / ejb-jar.xml。


    PS:我还没试过这种风格部署尚未。 YMMV。


    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 possibility to order the module initialization in Java EE 6 here which i also need for my application. Also, i would like to have an option to define some EJB properties in XML.

    Since the example is deployed as an EAR-project the order is defined in the application.xml. But in a WAR-deployed project, there is no application.xml. Now i wonder where i can define such informations? Or is it possible to use an application.xml somehow in a WAR-deployed-app?

    EDIT:

    Oops i didn't read the module-order-example right, in the first moment i thought it was about in which order the EJBs in my app are loaded. Of course i have only one module in my WAR-app, so ordering makes no sense.

    Ok, but as i'm at it, one big question remains (also altered the question title to reflect the change): What about the ejb-jar.xml? Can i somehow define stuff about my EJBs in XML (as its useful for some settings, to avoid recompilation)?

    解决方案

    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.

    这篇关于部署为WAR-only的EJB 3.1应用程序:ejb-jar.xml怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆