Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1682

BeanManager lookup fails with WELD-001328 when calling class is not a bean

XMLWordPrintable

      Trying to lookup the BeanManager using CDI.current().getBeanManager() from a class that is not a bean often results in the following exception:

      Caused by: org.jboss.weld.exceptions.IllegalStateException: WELD-001328: Unable to identify the correct BeanManager. The calling class nl.topicus.eduarte.services.CdiUtil is not placed in bean archive
              at org.jboss.weld.SimpleCDI.unsatisfiedBeanManager(SimpleCDI.java:89)
              at org.jboss.weld.servlet.StaticWeldProvider$EnhancedCDI.unsatisfiedBeanManager(StaticWeldProvider.java:39)
              at org.jboss.weld.SimpleCDI$ClassNameToBeanManager.findBeanManager(SimpleCDI.java:67)
              at org.jboss.weld.SimpleCDI$ClassNameToBeanManager.load(SimpleCDI.java:47)
              at org.jboss.weld.SimpleCDI$ClassNameToBeanManager.load(SimpleCDI.java:40)
              at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
              at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
              at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
              at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
              at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
              at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938)
              at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821)
              at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827)
              at org.jboss.weld.SimpleCDI.getBeanManager(SimpleCDI.java:105)
              at org.jboss.weld.SimpleCDI.getBeanManager(SimpleCDI.java:38)
              at nl.topicus.eduarte.services.CdiUtil.inject(CdiUtil.java:18)
      

      Changing the CdiUtil class to be non-final with @Dependent fixes the error, but now my class is a bean, even though it should not be used this way.

              rhn-engineering-jharting Jozef Hartinger
              papegaaij Emond Papegaaij
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: