discuss_ja@glassfish.java.net

Re: glassfishのクラスタリングについて

From: Yoshio Terada <Yoshio.Terada_at_Sun.COM>
Date: Fri, 08 Jan 2010 07:45:13 +0900

小向さん、

本件については、やはりバグのようです。

現時点でのワークアラウンドとしては、
下記のようにコード側を修正していただく事で
対応が可能になります。(絶対パスの指定が必要)

<%= response.encodeURL(request.getContextPath() + "/SomePage.jsp")%>

サンプルのHaJsp.jspを使った場合の修正

<FORM ACTION="<%= response.encodeURL(request.getContextPath()+"/
HaJsp.jsp")%>"

上記を試してみていただけないでしょうか。

寺田

On 2009/12/25, at 18:49, Yoshio Terada wrote:

> 小向さん、
>
> 環境を作って確認したのですが、cookie を無効にした
> 場合、
> たしかに、GF v2.1.1でも現象でますね。
> 大変失礼いたしました。少し調べてみます。
>
> 寺田
>
> Yoshio Terada さんは書きました:
>> 小向さん
>>
>> GlassFish のどちらのバージョンをご使用頂いている
>> か
>> わからないのですが、仮に最新のバージョンをご使
>> 用
>> 頂いていないのであれば、GlassFish v2.1.1で試してみ
>> て
>> 頂けないでしょうか。
>>
>> GlassFish v2.1.1 のダウンロード
>> Sun 製品版:
>> https://glassfish.dev.java.net/downloads/v2.1.1-final.html
>> GlassFish OSS 版:
>> http://www.sun.com/software/products/appsrvr/get_it.jsp
>>
>> 詳細:
>> **********************************************************************
>> GlassFish V2
>> Normally GlassFish 2 encodes session id to the URL automatically,
>> if the browser does not support cookies. Additional it is possible
>> to set the property enableCookies to never or always append the
>> session id to the URL.
>> But this property setting can be confusing, because of bug with
>> newly created sessions [1]. And also the property
>> enableURLRewriting is not working as expected.
>>
>>
>> GlassFish V2.1
>> GlassFish 2.1 fix this unexpected behaviour and ensures for all
>> cases, that setting enableCookies to true only stores the session
>> id in the cookie or false only encode session id to the URL.
>> As this version does also not support enableURLRewriting, the
>> automatic handling of the session id is not possible anymore.
>> So if your application should support all clients, even those which
>> do not accept cookies, you must add the following to the sun-
>> web.xml file [2].
>> <session-config>
>> <session-properties>
>> <property name="enableCookies" value="false" />
>> </session-properties>
>> </session-config>
>> The problem now is that all application URLs contain the session
>> id, which means:
>> ▪ User create bookmarks including the session id
>> ▪ Also when a webmaster add a backlink in his site
>> ▪ Crawling services save the URLs always with session id
>>
>>
>> GlassFish V2.1 Patch
>> If you want to avoid these problems and still run your application
>> with automatically handling of the session id, you can use the
>> unoffical Patch [3] provided by Jan Luehe [4], which backports
>> GlassFish 3 support for enableURLRewriting to the current version.
>> Just put this jar somewhere in the file system and define the path
>> in the Attribute classpath-prefix of the Tag java-config [5].
>>
>>
>> GlassFish V2.1.1
>> The problem does not occur in this version anymore. The automatic
>> handling of the session id works even without patch and without
>> special properties as usal.
>>
>>
>> GlassFish V3
>> GlassFish 3 provides better control of session id handling, because
>> it supports enableCookies and enableURLRewriting [6]. As default
>> both are true, so for automatic detection of cookie based or url
>> based session id is no entry in sun-web.xml neccessary.
>>
>> Conclusion
>> I prefere the solution of automatic url rewriting, even for SEO
>> applications. The site I-Coding itself is with serveral keys in
>> Googles top 10, even though it uses JSF and Session IDs.
>> Furthermore webmasters or developers can also submit application
>> URLs with an sitemap file to the main search engines.
>> Resources
>>
>>
>> [1] Issue 3972
>>
>> [2] /WEB-INF/sun-web.xml
>>
>> [3] Patch for GlassFish V2.1
>>
>> https://glassfish.dev.java.net/nonav/issues/showattachment.cgi/2265/patch.jar
>>
>> [4] Jan Luehe's Blog
>>
>> [5] /domains/domain1/config/domain.xml
>>
>> [6] Issue 4394
>>
>>
>> On 2009/12/24, at 18:52, 小向 政廣 wrote:
>>
>>> 始めまして、小向と申します。
>>>
>>> GlassFish 2.1 でクラスタリングを行なおうとしていま
>>> すが、ここ1ヵ月は まってしまっており
>>> 困っております。
>>>
>>> どなたかお分かりになる方がいらっしゃれば、ご
>>> 教授をお願い致します。
>>>
>>> ■構成・確認方法
>>> Linuxサーバ2台で、それぞれapache2.2.13、GlassFish2.1を
>>> インストール し、GlassFish側
>>> でクラスタ構成を行い動作確認をしました。
>>>
>>> apacheはmod_proxyを使い、apache2台から、GlassFishの2イン
>>> スタンスにリ クエストを割り
>>> 振るという構成にしております。
>>>
>>> 確認したアプリは、GlassFishについているサンプル
>>> clusterjspと同じよう に、画面で登録し
>>> た値をセッションに追加し続けていき、それをそ
>>> のまま画面に表示するとい うシンプルなもの
>>> です(ただし、jspではなくサーブレット)。
>>>
>>> GlassFishインスタンス1に処理が割り振られたのを確
>>> 認してから、GlassFish インスタンス1
>>> を落とし、ブラウザの画面をリロード、GlassFishイ
>>> ンスタンス2にリクエス トが振られ、登録
>>> した内容が保持されたことを確認する、という方
>>> 法でセッションの引継ぎを 確認しました。
>>>
>>> ■状況
>>> cookieが使えるクライアントからアクセスして動作
>>> 確認した場合は問題がな かったのですが、
>>> cookieが使えないクライアント(=携帯)からアク
>>> セスして、動作確認する と、クラスタ間でセッ
>>> ション情報が引き継がれないという状態になって
>>> おります。
>>>
>>> cookieが使えないクライアント用に、アプリも若干
>>> 修正、セッション保持の ためjsessionidを使
>>> うようにしています。
>>>
>>> GlassFish 2.1ではバグがあるらしく、cookieなしの場合
>>> は、そのままでは動 かなかったので
>>> sun-web.xmlに以下の設定を追加しています。
>>>
>>> <session-config>
>>> <session-properties>
>>> <property name="enableCookies" value="false" />
>>> </session-properties>
>>> </session-config>
>>>
>>> apacheはmod_proxyを使っており、以下のように設定し
>>> ました。
>>>
>>> ProxyPass /xxx balancer://clusterXxx/xxx stickysession=JSESSIONID
>>> ProxyPreserveHost On
>>> <Proxy balancer://clusterXxx >
>>> BalancerMember http://yyy01:23151loadfactor=1 route=xxx11
>>> BalancerMember http://yyy02:23151loadfactor=1 route=xxx21
>>> </Proxy>
>>>
>>> GlassFishのソースはダウンロードしてきて見ている
>>> のですが、問題の箇所が どこなのか検討
>>> がつかず・・・
>>>
>>> そもそもcookieが使えないとクラスタリングできな
>>> い、というオチな気もす るのですが、きちんと
>>> 説明できておらず・・・
>>>
>>> どなたかお分かりになる方がいらっしゃいました
>>> ら、ご教授よろしくお願い 致します。
>>>
>>>
>>
>
>