寺田さん
ご回答ありがとうございます。
2.1.1についても検証は行なっていたのですが、結果は同じでした。
(2.1.1ではenableCookiesの設定を追加しなくても動作するようになっていることについては
確認済み)
Sun GlassFish Enterprise Server v2.1.1 ((v2.1 Patch06)(9.1_02 Patch12)) (build b31g-fcs)
apacheからの振り先が1インスタンスの場合は動作するのですが、2インスタンスにするとセッショ
ンに値の保持ができなくなる、という挙動しております。
(クラスタ以前にセッションに値を保持できない)
以下についても組合せ、いくつかパターンを試しましたが、いずれも駄目でした。
web.xmlに<distributable/>する
jvmRouteを設定して、jsessionidにインスタンス名を追加する。
http://xxxx/app/;jsessionid=39b6a4a9da31e552a92d3ff8066d.<インスタンス名>
-----Original Message-----
From: Yoshio.Terada_at_Sun.COM [mailto:Yoshio.Terada_at_Sun.COM]
Sent: Friday, December 25, 2009 2:43 AM
To: discuss_ja_at_glassfish.dev.java.net
Subject: Re: glassfishのクラスタリングについて
小向さん
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が使えないとクラスタリングできな
> い、というオチな気もするのですが、きちんと
> 説明できておらず・・・
>
> どなたかお分かりになる方がいらっしゃいました
> ら、ご教授よろしくお願い致します。
>
>