GlassFish 3.1.1 b12 上的 CDI 生成错误“WELD-001408 Unsatisfied dependency”

发布于 2024-12-19 12:14:31 字数 867 浏览 3 评论 0 原文

我正在尝试在 Glassfish 3.1 上评估 CDI,尽管我已经成功使其正常工作,但当我尝试将代码拆分为单独的部署模块时,我收到了一个奇怪的错误。更具体地说:

我在同一个实用程序项目中捆绑了两个类(假设为 CommonLib.jar);类名是 UserDatabaseUserDatabaseEntityManager ,它们的定义如下(在本消息末尾的 PS 中)。 我还有一个带有 EJB3.1 模块的 EAR。

当我选择将 CommonLib.jar 部署为 EAR 的“捆绑库”时,出现以下错误:

部署期间发生错误:加载应用程序时出现异常:WELD-001408 类型 [EntityManager] 与限定符 [@UserDatabase] 的依赖关系不满足] 在注入点 [[field] @UserDatabase @Inject com.test.TestEJB.itemPersistenceEm]。请参阅 server.log 了解更多详细信息。

当我将 CommonLib.jar 部署为共享库(在 $glasshfish_installation_path/domains/domain1/lib 下复制的 jar 文件)时,我也会遇到与上面相同的错误 但是,如果我选择在 EJB 项目中只包含两个类(UserDatabaseUserDatabaseEntityManager)(因此它们在 EJB 模块内编译),那么注入工作正常。

我面临类加载器问题吗?有什么想法可以解决这个问题吗?

I'm trying to evaluate CDI on Glassfish 3.1 and even though I have accomplished to make it work well, when I'm trying to split my code in separate deployment modules I get a weird error. More specifically:

I have two classes bundled in the same utility project (let's say the CommonLib.jar); the classnames are UserDatabase and UserDatabaseEntityManager and their definitions are as below (in the PS at the end of this message).
I also have an EAR with an EJB3.1 module in it.

When I choose to deploy the CommonLib.jar as a "Bundled Library" of the EAR, then I get the following error:

Error occurred during deployment: Exception while loading the app : WELD-001408 Unsatisfied dependencies for type [EntityManager] with qualifiers [@UserDatabase] at injection point [[field] @UserDatabase @Inject com.test.TestEJB.itemPersistenceEm]. Please see server.log for more details.

Same error as above I get also when I deploy the CommonLib.jar as a shared library (jar file copied under $glasshfish_installation_path/domains/domain1/lib)
BUT, if I choose to just have the two classes (UserDatabase and UserDatabaseEntityManager) in the EJB project (thus they are compiled within the EJB module), then the injection works fine.

Am I facing a classloader issue? Any ideas how I can get past this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怪我鬧 2024-12-26 12:14:31

只是一个猜测,因为几天前我在 Glassfish 和 CDI 中遇到了一个非常相似的问题:Do you have a beans.xml in every JAR,即在 CommonLib.jar 和 EJB JAR,以便 CDI 扫描它们?

我的问题是由于我认为将 beans.xml 放入 EAR 中就足够了,但事实并非如此。

Just a guess, because I faced a very similar problem with Glassfish and CDI a few days ago: Do you have a beans.xml in every JAR, i.e. in the CommonLib.jar and the EJB JAR, so that CDI scans both of them?

My problem resulted from the fact that I thought placing a beans.xml into the EAR would be sufficient, which is not the case.

丘比特射中我 2024-12-26 12:14:31

Sounds like you're running into some of the Glassfish CDI integration issues we've found while working on Seam 3. It could be a couple of them, so you'll have to take a look at see which one it may be. Try testing on JBoss AS7 or Apache TomEE and see if you still have problems.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文