如果两者都捆绑在EAR中,如何在战争和EJB中运行CDI [英] How to get CDI in war AND EJB running if both are bundled in an EAR

查看:130
本文介绍了如果两者都捆绑在EAR中,如何在战争和EJB中运行CDI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个在EAR中组装的企业应用程序。此应用程序应包含一个或多个 ejb-jars 和一个或多个 war 。我想大量使用 CDI ,拦截器和生产者。在第一步中,我想使用 Log-Producer ,它位于应用程序所有区域的 ejb-jar 中。

I'm trying to build an enterprise application which is assembled in an EAR. This application should contain one or more ejb-jars and one or more war's. I want to make heavily use of CDI, Interceptors and Producers. In the first step I want to use a Log-Producer which is placed in the ejb-jar in all areas of the application.

我所做的是在ejb / META-INF和war / WEB-INF /文件夹中创建beans.xml。创建EAR是有效的。但是部署到Glassfish服务器(3.1)失败了,Interceptor类的ClassNotFoundException放在 ejb-jar 中。

What I did is creating a beans.xml in the ejb/META-INF and the war/WEB-INF/ folders. Creating the EAR works. But deploying to the Glassfish Server (3.1) fails with a ClassNotFoundException of the Interceptor Class which is placed in the ejb-jar.

删除EAR并在 war 中部署 ejb-jar 按预期工作。

Removing the EAR and deploying the ejb-jar inside the war works as expected.

由于模块化的原因以及有更多 war ejb-jar 部署的事实基于 EAR 非常受欢迎。

Due the reason of modularisation and the fact of having more war's and ejb-jar's a deployment based on an EAR is highly welcome.

所以问题是:有没有办法创建一个功能齐全的EAR,包括CDI和所有其他好东西?

So the question is: Is there a way to create a full featured EAR including CDI and all other nice stuff?

非常感谢你。

干杯
Ansgar

Cheers Ansgar

推荐答案

我们遇到过类似的问题使用JBoss 6上的CDI。我们的解决方法是将WAR部署者配置为使用一个全局类加载器范围与在EAR文件中部署的其他应用程序相关联。默认情况下,WAR文件中的每个应用程序都使用自己的类装入器范围。不幸的是我不知道Glassfish是否有类似的配置,但我想有。

We had similar problems with CDI on JBoss 6. The workaround for us was to configure the WAR deployer to use one global class loader scope togteher with the other applications deployed in the EAR file. By default each application in a WAR file uses its own class loader scope. Unfortunately I don't know whether there is a similar configuration available for Glassfish, but I guess there is.

有一个开放的票证,也可能与您的问题有关。

There is an open ticket on the glassfish issue tracker, which might to relate to your problem as well.

这篇关于如果两者都捆绑在EAR中,如何在战争和EJB中运行CDI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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