11

15:11:14,676 WARN FacesRequestAttributes:121 - FacesRequestAttributes がそのようなコールバックをサポートしていないため、属性 'purchaseController' の破棄コールバック [org.springframework.beans.factory.support.DisposableBeanAdapter@1059fd6] を登録できませんでした

この警告メッセージは私のログによく出てきます。有効期限が切れるたびに、すべてのマネージド Bean に対して。MyFaces Orchestra を使用しているため、一定時間後に有効期限が切れます。

で定義しorg.springframework.web.context.request.RequestContextListenerましたweb.xmlが、クラスパスにSpring jarのみがありません(つまり、クラスロードの問題ではありません)

FacesRequestAttribute のドキュメントには次のように書かれています。

注: ServletRequestAttributes とは対照的に、このバリアントは、リクエスト スコープでもセッション スコープでも、スコープ属性の破棄コールバックをサポートしていません。このような暗黙の破棄コールバックに依存している場合は、web.xml で Spring RequestContextListener を定義することを検討してください。

purchaseController、実際には単純なマネージド Bean (何も拡張せず、実装のみSerializable) であり、 で注釈が付けられてい@Controllerます。

アップデート1:

中の豆が影響を受けているようです@Scope("request")@Scope("session")したがって、この警告が適切なフローに危険をもたらすかどうかを知りたかったのです。つまり、これらのコールバックが本当に必要な場合です。そうでない場合は、lo4j 構成で警告をスキップします。

更新 2:

もう少し掘り下げたところ、これは時々しか起こらないようです. リスナーが使用されている場合、 ではなくをRequestContextHolder.currentRequestAttributes()返します。そのため、リスナーが機能せず、現在の属性が に設定されないことがあるようです。ServletRequestAttributesFacesRequestAttributesRequestContextHolder

更新 3:

のデバッグをオンにしましRequestContextListenerた。結果は次のとおりです。

07:21:31,518 DEBUG RequestContextListener:69 - Bound request context to thread: org.apache.catalina.connector.RequestFacade@1190ae9
07:21:31,518 DEBUG RequestContextListener:89 - Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@1190ae9
07:21:31,538  WARN FacesRequestAttributes:121 - Could not register destruction callback [org.springframework.beans.factory.support.DisposableBeanAdapter@11aa152] for attribute 'org.apache.myfaces.orchestra.conversation.AccessScopeManager' because FacesRequestAttributes does not support such callbacks
07:21:31,541  WARN FacesRequestAttributes:121 - Could not register destruction callback [org.springframework.beans.factory.support.DisposableBeanAdapter@1552393] for attribute 'localeController' because FacesRequestAttributes does not support such callbacks
....and so on, other request and session beans

Bean へのアクセスが試行される前に、リクエストが破棄されたようです。これは非常に奇妙です。これは、リスナー処理のサーブレット コンテナの実装に問題がある可能性がありますか?

4

2 に答える 2

11

のjavadocでFacesRequestAttributes、次のように読むことができます。

注:とは対照的にServletRequestAttributes、このバリアントは、リクエストスコープでもセッションスコープでも、スコープ属性の破棄コールバックをサポートしていません。このような暗黙的な破棄コールバックに依存している場合RequestContextListenerは、web.xmlでSpringを定義することを検討してください。

そして、確かに、のregisterDestructionCallback()方法は多くのことをFacesRequestAttributesしません:

public void registerDestructionCallback(String name, Runnable callback, int scope) {
    if (logger.isWarnEnabled()) {
        logger.warn("Could not register destruction callback [" + callback + "] for attribute '" + name +
                        "' because FacesRequestAttributes does not support such callbacks");
    }
}

しかし、私の理解では、RequestContextListener(あなたが宣言した)がこの仕事を引き受けます。そのrequestDestroyed(ServletRequestEvent requestEvent) 方法を以下に示します。

public void requestDestroyed(ServletRequestEvent requestEvent) {
   ServletRequestAttributes attributes =
           (ServletRequestAttributes) requestEvent.getServletRequest().getAttribute(REQUEST_ATTRIBUTES_ATTRIBUTE);
   ServletRequestAttributes threadAttributes =
           (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
   if (threadAttributes != null) {
       // We're assumably within the original request thread...
       if (attributes == null) {
           attributes = threadAttributes;
       }
       RequestContextHolder.resetRequestAttributes();
       LocaleContextHolder.resetLocaleContext();
   }
   if (attributes != null) {
       attributes.requestCompleted();
       if (logger.isDebugEnabled()) {
           logger.debug("Cleared thread-bound request context: " + requestEvent.getServletRequest());
       }
   }
}

そして、あなたがのjavadocを見ればServletRequestAttributes#requestCompleted()

すべてのリクエスト破棄コールバックを実行し、リクエスト処理中にアクセスされたセッション属性を更新します。

したがって、log4j構成でWARNを安全にスキップできると思います(ただし、少しのデバッグセッションでこれを確認することもできます)。

于 2010-01-16T21:26:35.753 に答える
5

追加してみました

<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

このフォーラムの投稿で erhan14 が提案したとおりです。

そして、その警告は消えました。それが役に立てば幸い。

于 2012-12-30T02:46:23.960 に答える