2006年12月29日 星期五

JSPWiki 安裝使用心得

從今年初還是去年末左右,看到Xexex's Java和其他二三事大大
的一篇尋求支援中文Wiki ,我就開始就跨入了JSPWiki 使用摸索之旅。

關於jsp的好處,這篇關於JSPWiki兩三事每個 team 都該裝個 Wiki 介紹很多就不細談了。

在JSPWiki安裝和使用中其實問題還蠻多的,因為版本更新還蠻快的。
當初我在使用的時候,就像Xexex's Java尋求中文解決方面一樣的問題。
比如說在2.23版 的搜尋需改成lucene(在jspwiki.properties),才可以搜尋中文,

接下來過程中要使用附加檔有中文檔名的、頁面連結有中文名稱的,那時候都會有問題。

而有人提及在tomcat的{catalina.home}\conf\server.xml設定中

<Connector port="8080"              
maxThreads="150"
....

.....
URIEncoding="UTF-8"
/>

需要加上設定URIEncoding="UTF-8"。可以解決部分中文 URI連結問題。
現在在使用到2.471以後的版本好像都自動解決了,不需手動設定。

但是我最大的問題在於它新版的登入功能始終有疑問。
好像不完整還是有bug,實際去觀察其實這問題蠻大的。
因為我用了兩三台電腦去安裝,它使用jass登入系統都不 work。
登入會一直產生invalid login。
這時只好翻查許多 bug回報和觀看log記錄檔

2006-12-28 11:21:17,631 [http-80-Processor25] ERROR com.ecyrd.jspwiki.auth.AuthenticationManager
- Couldn't retrieve login configuration.
Message=無針對 JSPWiki-container 配置的LoginModules
2006-12-28 11:21:17,631 [http-80-Processor25] ERROR com.ecyrd.jspwiki.auth.AuthenticationManager
No login context. Please double-check that
JSPWiki found your 'jspwiki.jaas' file or the contents have been appended to your regular JAAS file.
看起來是 jaas 配置的問題,不過這也很奇怪,因為一般使用預設的方式即可自動設定。
官方似乎有這樣的FAQ -Login does not work, create new users does
根據jspwiki.properties裡描述

# See the jspwiki.properties and jspwiki.jaas files for more details on
# how to do this. These files contain addition configuration options
# for the JSPWiki security policy and authentication, respectively, although
# the defaults should work fine. If you don't set the JRE properties,
# JSPWiki will use default versions from the WEB-INF directory.

# AUTHENTICATION
# For authentication, JSPWiki uses JAAS (Java Authentication and Authorization
# Service). The Authentication system is configured in the jspwiki.jaas
# file; by default it will attempt to leverage your servlet container's
# authentication services, if present. JSPWiki also can use its own
# authentication system, which is separate from the container.
有說跟沒說一樣 =.=
後來發現 JSPWiki的jaas程序是這樣子的,如果使用者自己有設定jaas則他會讀取該jaas設定。
若是沒有設定jaas,則JSPWiki會自動改用預設在WEB-INF\底下的jspwiki.jaas檔。
這個問題在此有提及到 多個wiki使用jaas問題(有點展露署光):D
Our default strategy is to try to install a JAAS configuration and supplemental J2SE policy if we detect that the user hasn't set them up already. We do this so that the administrator doesn't have to fool around with config files, and that it runs out of the box. On a multi-wiki system or one that's used in production, of course, we recommend setting the location of the JAAS and J2SE files manually so that they run JVM-wide.
這個立意良好的設定,在此卻是造成我們使用上的最大困擾。

為什麼呢? 後來我發現在我安裝在多台電腦上的JSPWiki唯一一台成功可以使用wiki登入系統的
電腦(最乾淨的 jdk、tomcat 沒有裝過其他可能會用到 jaas的web系統的)
在其log檔發現載入jaas設定部份
2006-11-23 10:09:18,921 [main] INFO com.ecyrd.jspwiki.auth.AuthenticationManager 
- JAAS not configured. Installing default configuration:
file:/C:/jakarta-tomcat-5.0.28/webapps/JSPWiki/WEB-INF/jspwiki.jaas.
You can set the java.security.auth.login.config system property to point to your jspwiki.jaas file,
or add the entries from jspwiki.jaas to your own JAAS configuration file.
而在不行的電腦上log 為
2006-12-28 11:20:48,053 [Thread-0] INFO com.ecyrd.jspwiki.auth.AuthenticationManager 
- JAAS already configured by some other application (leaving it alone...)

知道為什麼了嗎?因為我其他的電腦上都裝過一些會用到web services的元件,其中也可能有用到
jaas的東西,所以他都讀到其他那個的jaas設定,而WEB-INF\jspwiki.jaas檔完全就不會讀到了,
除非我把系統正規讀到jaas設定檔,加入jspwiki.jaas的部分,或是移掉可能有設定到jaas 的部份。
可惜我還是找不到那個設定 jaas的檔在哪裡。

最後在只好利用客製化設定 在系統變數加上參數
Customizing JSPWiki's JAAS Configuration
export CATALINA_OPTS="-Djava.security.auth.login.config==/etc/jspwiki.jaas"
or
set CATALINA_OPTS="-Djava.security.auth.login.config==C:\xxx\jspwiki.jaas"
才使登入系統可以正確操作。
其他又可以開始玩換佈景和加入些外掛插件增強功能了
不過插件的相容版本問題,又是挺討厭的。
目前使用2.4.87版本

沒有留言: