1

私の問題: 確かではありませんが、SAPが提供する認証サーブレットフィルターがあり、SAPのデフォルトログオンページにリダイレクトしていると思います(もちろん、xml応答を返さないため問題を引き起こしています)。呼び出されFullAjaxExceptionHandlerないようにします。根本的な原因が実際に何であるかを判断するための助けを探しているか、それを修正するための代替手段があるかどうか.

私の環境:

  • SAP Netweaver 7.4 (JSF 2.1.x をサポートするサーブレット 2.5)
  • SAP JVM 6.1 (SAP の 1.6 jvm)
  • モハラ 2.1.29
  • オムニフェイス 1.11

バックグラウンド:

1 分に設定されたサンプル アプリケーションがありsession-config session-timeout、Omnifaces が でFullAjaxExceptionHandlerFactory構成されていますfaces-config.xml

web.xml

...

<error-page>
    <error-code>500</error-code>
    <location>/WEB-INF/errorPage.xhtml</location>
</error-page>
<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/WEB-INF/viewExpired.xhtml</location>
</error-page>
<session-config>
    <session-timeout>1</session-timeout>
</session-config>
... 

顔-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd" version="2.1">

<factory>
    <exception-handler-factory>org.omnifaces.exceptionhandler.FullAjaxExceptionHandlerFactory</exception-handler-factory>
</factory>
...

Netweaver が機能すると判断した方法は、1 分後にセッションを「期限切れ」とマークすることですが、セッション自体はすぐにはクリーンアップされません (これは Web コンテナーでは一般的であることを理解しています)。セッションの有効期限が切れた後、セッションがサーバーによって完全に削除される前に ajax リクエストを送信すると、有効になりFullAjaxExceptionHandler、View Expired ページが適切に表示されます。ただし、サーバーが期限切れのセッションを既にクリーンアップしている場合は何も起こらず、物理的な更新が実行されるまでページは「死んでいる」ように見えます。

@balusc による多くの回答を読んだことから、SAP が提供する http フィルターが作動していると思われます。これにより、ajax 要求が SAP ログイン ページにリダイレクトされます。これが、アプリケーションが機能していない理由です。

何が原因であるかを確実に特定する方法はありますか?それがサーバー提供のフィルターである場合、それをオーバーライドする方法はありますか?

4

1 に答える 1

1

BalusC に感謝します。あなたは私を正しい方向に押しやった。

SAP Netweaver には、global-web.xmlいくつかのデフォルト機能を定義するファイルがあります。それらの1つは次のとおりです。

<filter>
    <filter-name>AuthenticationFilter</filter-name>
    <filter-class>com.sap.engine.services.servlets_jsp.server.servlet.AuthenticationFilter</filter-class>
</filter>

<filter-name>したがって、私が行ったことは、SAP の認証フィルターを拡張するクラスを提供して、自分の web.xmlでも同じように使用されました。

<filter>
    <filter-name>AuthenticationFilter</filter-name>
    <filter-class>com.example.AjaxAwareAuthenticationFilter</filter-class>
</filter>

は同じなので、<filter-name>私のローカルで定義されているものが優先されweb.xmlます。

これが私のクラスです:

package com.example;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.sap.engine.services.servlets_jsp.server.servlet.AuthenticationFilter;

public class AjaxAwareAuthenticationFilter extends AuthenticationFilter {
    @Override
    public void destroy() {
        super.destroy();
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {

        HttpServletRequest httpRequest = (HttpServletRequest) request;

        HttpSession session = httpRequest.getSession(false);
        if (session == null && "partial/ajax".equals(httpRequest.getHeader("Faces-Request"))) {
                // JSF ajax request. Return special XML response which instructs
                // JavaScript that it should in turn perform a redirect.
                response.setContentType("text/xml");
                response.getWriter()
                    .append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
                    .printf("<partial-response><redirect url=\"%s\"></redirect></partial-response>",
                            httpRequest.getContextPath());
        } else {
            super.doFilter(request, response, chain);
        }
    }

    @Override
    public void init(FilterConfig config) throws ServletException {
        super.init(config);
    }
}
于 2015-09-16T13:37:58.073 に答える