How to get CDI in war AND EJB running if both are bundled in an EAR

会有一股神秘感。 提交于 2019-12-12 17:15:26

问题


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.

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.

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

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.

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

Thank you very much.

Cheers Ansgar


回答1:


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.



来源:https://stackoverflow.com/questions/7914478/how-to-get-cdi-in-war-and-ejb-running-if-both-are-bundled-in-an-ear

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