WELD-001409 Ambiguous dependencies for type [EagerBeansRepository]

ぃ、小莉子 提交于 2019-12-10 15:54:14

问题


I'm trying to migrate my JSF application to CDI. I have implented the following changes:

  • Added an empty beans.xml file to WEB-INF
  • Changed @ManagedBean 's to @Named
  • Changed All the scopes I have to CDI Scopes (Session, View, Request)
  • Changed all @EJB and @ManagedProperty to @Inject

However, an Omnifaces error is preventing deployment as I'm getting the following error three times:

org.jboss.weld.exceptions.DeploymentException: WELD-001409 Ambiguous dependencies for type [EagerBeansRepository] with qualifiers [@Default] at injection point [[BackedAnnotatedField] @Inject private org.omnifaces.ApplicationListener.eagerBeansRepository]. Possible dependencies [[Managed Bean [class org.omnifaces.cdi.eager.EagerBeansRepository] with qualifiers [@Any @Default], Managed Bean [class org.omnifaces.cdi.eager.EagerBeansRepository] with qualifiers [@Any @Default]]]

I have downgraded to Omnifaces 1.8.1 and the deployment was successful. Why Omnifaces 2.0 resulting in this error?

Development Environment:

  • Glassfish 4
  • Omnifaces 2.0
  • JSF (Mojarra 2.2.0)
  • WELD-000900 2.0.0 (SP1)

回答1:


This exception suggests that OmniFaces JAR (specifically, the JAR containing the mentioned ambiguous class, which is in your particular case EagerBeansRepository) is duplicated in runtime classpath. Provided that the JAR is properly placed in /WEB-INF/lib of the webapp and not elsewhere, then this can happen if GlassFish work folders are not properly cleaned up before deploy. Particularly the GlassFish Eclipse plugin is known to fail in this. You'd need to manually clean up the GlassFish work folders in /glassfish/domains/[domainname].

By the way, while you're at it, I strongly recommend to upgrade to GlassFish 4.1 as well. GlassFish 4.0 has like every first GlassFish release (all the hassle to get it ready as "First Java EE X Application Server" along with every new Java EE API release) way too many childhood bugs.



来源:https://stackoverflow.com/questions/29282236/weld-001409-ambiguous-dependencies-for-type-eagerbeansrepository

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