4

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)
BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
fareed
  • 2,892
  • 5
  • 32
  • 56
  • This exception suggests that OmniFaces JAR is duplicated in runtime classpath. Are you deploying a WAR or EAR? Where is the OmniFaces JAR placed? Are you sure that GlassFish work folders are properly cleaned up before deploy? By the way, while you're at it, I strongly recommend to upgrade to GlassFish 4.1 as well. – BalusC Mar 26 '15 at 15:30
  • @BalusC I have cleared Glassfish work folder and deployed without any errors. Thanks. Any articles or links about why should I upgrade to GlassFish 4.1? – fareed Mar 26 '15 at 15:49
  • @BalusC Also can you put your comment as an answer so I accept it? Thanks – fareed Mar 26 '15 at 15:51

1 Answers1

5

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.

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
  • what do you mean by clean? Delete the folder? – uesports135 Apr 12 '16 at 00:54
  • 1
    @uesports135: delete the folder's contents, yes. Folder itself can also (GF will autocreate new), but is unnecessary. – BalusC Apr 12 '16 at 07:03
  • This does not solve the issue. And I am using GF 4.1 – uesports135 Apr 13 '16 at 01:16
  • @uesports135: Then it's duplicated elsewhere. Hard to point out based on information provided so far. The answer in its current form at least contains all clues where to look. – BalusC Apr 13 '16 at 07:23
  • Is there a specific folder in the domains/domain1 directory to check for? I have glassfish integrated with IntelliJ so deleting all the directory's contents screws up my configuration. – uesports135 Apr 13 '16 at 12:53
  • @uesports135: Sorry, not sure about IntelliJ integration as I've never used it. – BalusC Apr 13 '16 at 20:48