-
1. Re: WELD-000047: Specializing bean must extend another bean
tremes Apr 11, 2014 9:20 AM (in response to blackhm)1 of 1 people found this helpfulHi Geoffrey!
It looks like the exception is correct in this case. From point of CDI spec view DeviceSimpleDTOMapper is session bean and DeviceSimpleDTOMapperExtended is not. I think it's not possible to specialize session bean with managed bean. CDI spec states:
3.2.4. Specializing a session bean
If a bean class of a session bean X is annotated @Specializes, then the bean class of X must
directly extend the bean class of another session bean Y. Then X directly specializes Y, as defined
in Section 4.3, “Specialization”.
If the bean class of X does not directly extend the bean class of another session bean, the
container automatically detects the problem and treats it as a definition error.
-
2. Re: WELD-000047: Specializing bean must extend another bean
blackhm Apr 11, 2014 9:51 AM (in response to tremes)Thanks for your reply.
It's better. I've added annotation @Singleton on the specialized bean, and it seems that weld accept the specialization.
However, i reach another error :
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type IObjectMapper with qualifiers @ObjectMapperDef
at injection point [BackedAnnotatedField] @Inject @ObjectMapperDef private com.bhm.cgw.omconnect.mapping.output.device.PastilleDetailsDTOCustomizer.simpleDtoMapper
at com.bhm.cgw.omconnect.mapping.output.device.PastilleDetailsDTOCustomizer.simpleDtoMapper(PastilleDetailsDTOCustomizer.java:0)
It's related to the specialized beans. Weld give me some beans which match by type (but none by qualifier) which doesn't contains specialized beans or specializing beans.
-
3. Re: WELD-000047: Specializing bean must extend another bean
tremes Apr 11, 2014 10:24 AM (in response to blackhm)How does the interface IObjectMapper look like? I guess qualifiers are inherited in this case.
-
4. Re: WELD-000047: Specializing bean must extend another bean
blackhm Apr 11, 2014 11:03 AM (in response to tremes)Here the IObjectMapper interface :
public interface IObjectMapper {
public Object fromBean(Object ob, Class<?> dstClass) throws ObjectMapperException;
public Object fromBean(Object ob, Class<?> dstClass, Map<Object, Object> properties) throws ObjectMapperException;
// This method allow to specify the src class from which the mapping have to be searched
public Object fromBean(Object ob, Class<?> dstClass, Class<?> srcClass) throws ObjectMapperException;
public Object fromBean(Object ob, Class<?> dstClass, Class<?> srcClass, Map<Object, Object> properties) throws ObjectMapperException;
}
Here the ObjectMapperDef qualifier annotation :
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public @interface ObjectMapperDef {
public Class<?> src();
public Class<?> dst();
}
Here a more complete trace of the error :
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type IObjectMapper with qualifiers @ObjectMapperDef
at injection point [BackedAnnotatedField] @Inject @ObjectMapperDef private com.bhm.cgw.omconnect.mapping.output.device.PastilleDetailsDTOCustomizer.simpleDtoMapper
at com.bhm.cgw.omconnect.mapping.output.device.PastilleDetailsDTOCustomizer.simpleDtoMapper(PastilleDetailsDTOCustomizer.java:0)
WELD-001475: The following beans match by type, but none have matching qualifiers:
- Session bean [class com.bhm.tools.pastille.resource.mapping.CommandFacadeToAdapterMapper with qualifiers [@ObjectMapperDef @Any]; local interfaces are [IObjectMapper],
- Session bean [class com.bhm.cgw.omconnect.mapping.output.CommandListDTOMapper with qualifiers [@ObjectMapperDef @Any]; local interfaces are [IObjectMapper],
- Session bean [class com.bhm.cgw.omconnect.mapping.output.CommandDTOMapper with qualifiers [@ObjectMapperDef @Any]; local interfaces are [IObjectMapper],
- Session bean [class com.bhm.tools.pastille.webresource.mapping.output.RootDTOMapper with qualifiers [@ObjectMapperDef @Any]; local interfaces are [IObjectMapper],
- Session bean [class com.bhm.cgw.omconnect.mapping.output.DeviceListDTOMapper with qualifiers [@ObjectMapperDef @Any]; local interfaces are [IObjectMapper],
- Session bean [class com.bhm.tools.pastille.resource.mapping.CommandDefinitionToFacadeMapper with qualifiers [@ObjectMapperDef @Any]; local interfaces are [IObjectMapper]
The list give me all beans which implement IObjectMapper exception specializing and specialized beans.
-
5. Re: WELD-000047: Specializing bean must extend another bean
tremes Apr 14, 2014 11:22 AM (in response to blackhm)Well the class com.bhm.cgw.omconnect.mapping.output.device.PastilleDetailsDTOCustomizer looks like quite different story. How does the injection point exactly looks like? ...and how does the class looks? I would guess members values (src, dst) for @ObjectMapperDef do not match....but that's just my guess.