Details
-
Type:
Bug
-
Status: Resolved (View Workflow)
-
Priority:
Major
-
Resolution: Done
-
Affects Version/s: 1.1.2.Final
-
Fix Version/s: 1.1.4.Final
-
Component/s: None
-
Labels:None
Description
BeanDeployerEnvironment has 2 methods which - combined with seam-config - break @Specializes:
public class BeanDeployerEnvironment {
|
|
|
private final Map<WeldClass<?>, AbstractClassBean<?>> classBeanMap;
|
|
|
protected void addAbstractClassBean(AbstractClassBean<?> bean)
|
{
|
...
|
classBeanMap.put(bean.getWeldAnnotated(), bean);
|
...
|
}
|
|
|
public AbstractClassBean<?> getClassBean(WeldClass<?> clazz)
|
{
|
if (!classBeanMap.containsKey(clazz))
|
{
|
return null;
|
}
|
...
|
}
|
|
Here's what happens:
In this use case I have a bean RepositoryStartupService, which is extra configured by seam-config.
It is also specialized by TestRepositoryStartupService (for tests).
1) First addAbstractClassBean is called with these parameters:
bean = Managed Bean [class org.drools.guvnor.server.repository.RepositoryStartupService] with qualifiers [@Any @Default @Named]
|
bean.bean.getWeldAnnotated() = public@Named @XmlConfiguredBean @ApplicationScoped @XmlId class org.drools.guvnor.server.repository.RepositoryStartupService
|
2) Later on, getClassBean is called to find the parent class RepositoryStartupService:
clazz = public@Named @ApplicationScoped class org.drools.guvnor.server.repository.RepositoryStartupService
|
which returns null because the @XmlConfiguredBean bits are missing.
So I get this exception message:
org.jboss.weld.exceptions.DefinitionException: WELD-000047 Specializing bean must extend another bean: Managed Bean [class org.drools.guvnor.server.repository.TestRepositoryStartupService] with qualifiers [@Any @Default]
|
One can argue that since seam-config is not configuring TestRepositoryStartupService a failure is normal,
but even in that case the exception message is very misleading, as looking at the code TestRepositoryStartupService clearly extends RepositoryStartupService which is also a bean.
Note the far-reaching effect of this issue:
Any bean that is specialized by or specializes another bean cannot be configured by seam-config.
If @Specializes is used and 1 of the 2 involved beans is seam-configured, weld crashes always (even if the subclass is an @Alternative).