【发布时间】:2020-11-01 01:07:24
【问题描述】:
当我尝试在应用程序范围 bean 中注入请求范围 bean 时,出现以下错误。
Method threw 'org.jboss.weld.contexts.ContextNotActiveException' exception. Cannot evaluate com.example.flow.txn.TxnMessageProcessor$Proxy$_$$_WeldClientProxy.toString()
代码参考:
@ApplicationScoped
public class TxnMessageObserver {
private static final Logger logger = LoggerFactory.getLogger(TxnMessageObserver.class);
@Inject
private TxnMessageProcessor processor;
//message is observed here
public void postConstruct(@Observes @Initialized(ApplicationScoped.class) Object o) {
logger.info("Subscribing to queue [{}] for msg.", queue);
consumer.subscribe(queue);
}
}
@RequestScoped
public class TxnMessageProcessor {
private static final Logger logger = LoggerFactory.getLogger(TxnMessageProcessor.class);
//all processing happens here
}
我需要处理请求范围内的每条消息。
【问题讨论】:
-
有任何反馈吗?我还没有投反对票,但请阅读idownvotedbecau.se/beingunresponsive(我注意到您提出了一个相关问题,因此非常感谢您(即使在您的“变色龙化”之后)对答案的反馈(并且有礼貌)