EAR与单独的EJB + WAR [英] EAR vs separate EJB + WAR

查看:199
本文介绍了EAR与单独的EJB + WAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将应用程序部署为EAR(使用1个EJB和1个WAR模块)与单独的模块有什么区别?我想使用GlassFish 3 Web配置文件,但它不支持EAR存档。我可以简单地将EJB和WAR用作单独的模块吗?还有其他选择吗?

What's the difference in deploying application as EAR (with 1 EJB and 1 WAR module) vs separate modules? I want to use GlassFish 3 web profile but it does not support EAR archive. Can I simply use EJB and WAR as separate modules? Any other options?

推荐答案

3种部署变体之间似乎有些混淆:

There seems to be some confusion between 3 variants of deployment:


  1. 包含EJB和WEB模块的EAR

  2. 部署单独的EJB模块和单独的WEB模块

  3. 部署包含EJB类或EJB jar的WEB模块。

在第一种情况下,您在逻辑上有一个应用程序,但是分为两层。 WEB模块与EJB模块隔离,因为它可以使用EJB模块中的类,但EJB模块不能使用来自WEB模块的类。由于它是单个应用程序,因此可以使用EJB bean的本地访问,并且EJB bean的注入按预期工作。

In the first situation, you have logically one application, but one that is divided in two tiers. The WEB module is isolated from the EJB module in the sense that it can consume classes from EJB module, but the EJB module can not consume classes from the WEB module. Since it's a single application local access to EJB beans can be used and injection of EJB beans works as expected.

在第二种情况下(您似乎在指的是你的问题)没有一个逻辑的单一应用程序,但实际上是两个独立的模块。它们确实在同一个JVM中运行,但官方Java EE不允许使用本地访问并且必须使用远程访问(尽管实际上本地访问通常仍然有效)。此外,在Web模块中的bean中注入EJB bean不能直接使用简单的 @EJB 注释,而是使用查找属性来指定全局JNDI名称。

In the second situation (which you seem to be referring to in your question) there isn't a logical single application, but really two separate modules. They do run in the same JVM, but officially Java EE does not allow to use local access and remote access has to be used (although practically local access often works anyway). Also, injection of EJB beans in beans in the web module does not work directly with a simple @EJB annotation, but instead the lookup attribute has to be used that specifies the global JNDI name.

最后,第三种情况(你似乎没有提及,但是'主页'提及)有点类似于第一个,但在这种情况下没有层和隔离。 EJB bean可以直接从其余的Web模块访问所有类。

Finally, the third situation (which you don't seem to mention, but 'home' mentions) is a bit similar to the first one, but there are no tiers and isolation in this case. EJB beans can access all classes from the rest of the web module directly.

Web配置文件仅支持最后的部署情况。不支持EAR和独立EJB部署。

The web profile only supports this last deployment situation. Both EAR and standalone EJB deployments are not supported.

这篇关于EAR与单独的EJB + WAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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