I'm trying to use a POJO as CDI producer for injecting the right EJB but I get org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001308.
This is my producer POJO
public class STGatewayUtilProducer {
@Produces
@Chosen
public ISTGatewayUtil getISTGatewayUtil(Instance<STGatewayWSUtil> ws, Instance<STGatewayMQTTUtil> mqtt, ConfigurationManager cm) {
switch(cm.getGatewayProtocol()) {
case ConfigurationManager.GATEWAY_PROTOCOL_TYPE_MQTT:
return mqtt.get();
default:
return ws.get();
}
}
}
This is the qualifier definition:
@Qualifier
@Target({ TYPE, METHOD, PARAMETER, FIELD })
@Retention(RUNTIME)
@Documented
public @interface Chosen {}
And those are the EJB declarations:
@Stateless
public class STGatewayMQTTUtil implements Serializable, ISTGatewayUtil {
...
}
@Stateless
public class STGatewayWSUtil implements Serializable, ISTGatewayUtil {
...
}
Finally, this is the way I'm injecting the EJB:
@Inject
@Chosen
private Instance<ISTGatewayUtil> gtwUtil;
I'm facing the problem both with JBoss AS 7 and WildFly 10.
Edit
I found the core of my problem! I declared a common abstract
parent class which implements the ejb interface and let my session beans extend it: using this structure the beans can't be resolved.
Instead, if i move the implements
clause on session beans the problem disappear: may someone explain me what's wrong with my class hierarchy?