Message driven bean calling EJB produces WELD-001303 No active contexts for scope type javax.enterprise.context.RequestScoped
timsmail Oct 22, 2013 10:26 AMLooking for help resolving the stated error. I am running on JBoss AS 7.1.2, WELD 1.8, and receive the error WELD-001303 No active contexts for scope type javax.enterprise.context.RequestScoped. Since this is an unchecked exception it is being swallowed by the app server, but I am picking this error up in my app monitoring tool logs. The code structure is a message driven bean making a call to an EJB. The code is using annotations and CDI. Any insight to how why this error is occurring is appreciated. Code samples provided below.
MessageConsumerBean.java
public abstract class MessagingConsumerBean implements MessageListener {
@EJB
protected MessagingClient messagingClient;
@Resource
protected MessageDrivenContext ctx;
@Inject ...
......
public void onMessage(final Message message) {
messagingClient.doSomething();
.....
}
TestConsumerBean.java
package com.test
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
@MessageDriven(
name = "TestConsumerBean",
activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination",
propertyValue = "Datacache"),
@ActivationConfigProperty(propertyName = "connectorClassName",
propertyValue = "org.hornetq.core.remoting.impl.netty.NettyConnectorFactory"),
@ActivationConfigProperty(propertyName = "consumerMaxRate", propertyValue = "-1"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "reconnectAttempts", propertyValue = "-1"),
@ActivationConfigProperty(propertyName = "setupAttempts", propertyValue = "-1"),
@ActivationConfigProperty(propertyName = "consumerWindowSize", propertyValue = "65536") })
@TransactionManagement(value = TransactionManagementType.CONTAINER)
@TransactionAttribute(value = TransactionAttributeType.REQUIRED)
public class TestConsumerBean extends MessagingConsumerBean {
}
MessagingClient.java
public interface MessagingClient {
....
}
MessagingClientBean .java
@Stateless
@Remote(MessagingClient.class)
public class MessagingClientBean implements MessagingClient {
@Inject
.....
}