@RequestScoped
CDI BeanをJava EE 7 WebSocketエンドポイントに挿入します。WebSocketエンドポイントとCDIインジェクション:スコープのアクティブなコンテキストがありません。RequestScoped
ただし、エラーWELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped
が発生しています。
私は間違って何をしていますか、なぜそれが不可能なのですか?
@ServerEndpoint("/serverpush")
public class ContratoEndpoint {
@Inject
private Storage storage;
}
そして、私は次のスタックトレースを取得しています:
org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped
at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:689)
at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.getIfExists(ContextualInstanceStrategy.java:90)
at org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.getIfExists(ContextualInstanceStrategy.java:165)
at org.jboss.weld.bean.ContextualInstance.getIfExists(ContextualInstance.java:63)
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:83)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.getInstance(ProxyMethodHandler.java:125)
@BonanzaOne @Rouliboyこれは良いアプローチですが、私は最初に** Weld **に存在するものを試してみます。 Weld APIに依存関係を設定した場合、メソッド/クラスに、事前に定義されたインターセプタバインド '@ ActivateRequestContext'を使用して注釈を付けることができます。詳細については、[Weld Doc](http://docs.jboss.org/weld/reference/latest/en-US/html_single/#_request_context)を参照してください。これはもともとSE環境用に設計されていますが、EEでも同じように動作するはずです。 – Siliarus
@Siliarus:私はこれを知らなかった、情報のおかげで! – Rouliboy