版權(quán)所有:(xiaodaoxiaodao)藍(lán)小刀
??
xiaodaoxiaodao@gmail.com
http://m.tkk7.com/xiaodaoxiaodao/archive/2007/09/16/145520.html
轉(zhuǎn)載請(qǐng)注明來源/作者
?
?
Alfresco2.1
下載和安裝
Alfresco
是一個(gè)開放源碼,開放標(biāo)準(zhǔn)的內(nèi)容知識(shí)庫. 兼容JBoss Portal 2.0與JSR-168. Java Server Faces圖形接口框架. 可訪問CIFS/SMB等.
Alfresco
主要是基于Spring, Hibernate, Lucene等開發(fā). Alfresco公司利用開源代碼Java中部分內(nèi)容,尤其是利用了JBoss程序服務(wù)器和Spring開發(fā)架構(gòu),創(chuàng)建了目錄知識(shí)庫。
?
?
1
.
下載和安裝alfresco(內(nèi)嵌tomcat的版本)
①
下載和安裝alfresco(這里下載的版本為
alfresco-community-tomcat-2.1.0.zip
)
下載地址為:http://sourceforge.net/project/showfiles.php?group_id=143373
下載后解壓到一個(gè)目錄,這里解壓到E:\project\alfresco,解壓后可以看到目錄結(jié)構(gòu)如下:
?
啟動(dòng)alfresco/alf_start.bat,訪問http://localhost:8080/alfresco/即可看到alfresco登錄界面(默認(rèn)管理員登陸 用戶名:admin,密碼:admin)。
?
這時(shí)可以看到alfresco/tomcat/webapps目錄下的alfresco.war包被解壓為alfresco文件夾。
?
注:
用記事本打開alfresco/alf_start.bat可以看到其中內(nèi)容:
call "%~dp0alfresco.bat" start
?????????
(%~dp0表示查找bat文件所在目錄)
然后alf_start.bat調(diào)用alfresco.bat,在alfresco/alfresco.bat中有一行:
call "%CATALINA_HOME%\bin\startup.bat"
可以看到最終運(yùn)行的還是Tomcat。
?
②
當(dāng)出現(xiàn)下面這些出錯(cuò)信息時(shí),只要知道其出錯(cuò)的原理,就很容易解決它。
⑴
org.alfresco.error.AlfrescoRuntimeException
不能直接在alfresco/tomcat/bin中運(yùn)行startup.bat啟動(dòng)Tomcat,會(huì)報(bào)錯(cuò):
00:31:34,687 ERROR [web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'dictionaryRepositoryBootstrap' defined in class path resource [
alfresco/
core-services-context.xml
]: Invocation of init method failed; nested exception i
s org.alfresco.error.AlfrescoRuntimeException: Failure during rollback: org.alfr
esco.repo.dictionary.DictionaryRepositoryBootstrap$1@2589c3
Caused by:
org.alfresco.error.AlfrescoRuntimeException
: Failure during rollback: org.alfres
co.repo.dictionary.
DictionaryRepositoryBootstrap
$1@2589c3
?????
?
出錯(cuò)是因?yàn)樵?span lang="EN-US">alfresco/tomcat/bin中運(yùn)行startup.bat啟動(dòng)Tomcat,找不到相應(yīng)的HSQL database的初始化信息,可以參考下面的 ⑶仔細(xì)思考一下。
?
注1:
思考之后,你也許會(huì)嘗試把alfresco/alf_data/hsql_data這個(gè)文件夾放到alfresco/tomcat/bin目錄中,然后再次運(yùn)行startup.bat啟動(dòng)Tomcat,你可以看一下運(yùn)行結(jié)果會(huì)怎樣,這會(huì)幫助你理解alfresco初始化)。
?
注2:
如果你使用的是mysql數(shù)據(jù)庫,而mysql數(shù)據(jù)庫沒有運(yùn)行mysqld啟動(dòng)的話,也會(huì)報(bào)上面錯(cuò)誤。
?
⑵
在alfresco.bat中這樣幾行字:
rem The following options are only required for Sun JVMs prior to 1.5 update 8
set JAVA_OPTS=%JAVA_OPTS% -XX:CompileCommand=exclude,org/apache/lucene/index/IndexReader$1,doBody -XX:CompileCommand=exclude,org/alfresco/repo/search/impl/lucene/index/IndexInfo$Merger,mergeIndexes -XX:CompileCommand=exclude,org/alfresco/repo/search/impl/lucene/index/IndexInfo$Merger,mergeDeletions
注意上面綠色信息,如果你的JDK版本過低的話,上面這一行字是必須的。
?
注:
java -version
可以查看JDK版本
我本機(jī)版本查看如下:
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)
J2SE Development Kit 1.5 update 5
如上,說明JDK版本是J2SE Development Kit 1.5 update 5,那么上面alfresco.bat中的幾行字按照上面綠色注釋也是必須加的。
?
不過我嘗試去掉上面alfresco.bat中的幾行字,并沒有報(bào)錯(cuò),估計(jì)1.5 update 5到1.5 update 7中alfresco.bat中的幾行字也都是可以去掉的。
?
要想去掉上面alfresco.bat中的幾行字,必須下載JDK的相應(yīng)版本,下載地址為:http://java.sun.com/products/archive/
?
⑶
alfresco/alf_data
下面有一個(gè)hsql_data文件夾,存放的是一些HSQL database的初始化信息,如果刪除,也會(huì)報(bào) ⑴中的錯(cuò)
hsql_data
下面有兩個(gè)文件
alfresco.properties
:配置HSQL數(shù)據(jù)庫的一些初始化參數(shù)
alfresco.script
:創(chuàng)建HSQL數(shù)據(jù)庫用戶的sql語句,默認(rèn)創(chuàng)建兩個(gè)HSQL用戶(如下)。
CREATE USER SA PASSWORD ""
CREATE USER ALFRESCO PASSWORD "ALFRESCO"
?
注:
啟動(dòng)alfresco時(shí),如果HSQL數(shù)據(jù)庫被更改,alfresco.properties文件會(huì)被更新,文件中的modified=no更新為modified=yes
?
⑷
清空初始化信息和緩存(呵呵,當(dāng)你進(jìn)入http://localhost:8080/alfresco/進(jìn)行了一些CRUD的操作之后就不要隨便清空了,這會(huì)重新初始化你的HSQL數(shù)據(jù)庫)。
比較重要的一點(diǎn)是在出錯(cuò)之后如果使用alf_start.bat重新啟動(dòng)alfresco,最好要?jiǎng)h除清空文件夾:alfresco/alf_data(見注1),alfresco/tomcat/temp,否則很可能會(huì)報(bào)錯(cuò)。
?
注1:
使用alf_start.bat重新啟動(dòng)alfresco后,會(huì)在alfresco/alf_data下生成4個(gè)文件夾:lucene-indexes/contentstore.deleted/contentstore/audit.contentstore
?
注2:
其中alfresco/alf_data/hsql_data文件夾千萬不能刪除,原因如 ⑶所述
?
注3:
另外,為徹底一點(diǎn),你也可以清空alfresco/tomcat/work(tomcat下的/緩存文件夾)。
?
⑸
如果出現(xiàn)下面錯(cuò)誤:
Exception in thread "
HSQLDB
Timer @3de2df"
java.lang.NullPointerException
??????? at org.hsqldb.lib.HsqlTimer.nextTask(Unknown Source)
??????? at org.hsqldb.lib.HsqlTimer$TaskRunner.run(Unknown Source)
??????? at java.lang.Thread.run(Thread.java:595)
可能是alfresco關(guān)閉時(shí)不正常,可以再次運(yùn)行alfresco/alf_stop.bat進(jìn)行關(guān)閉。
?
⑹
如果刪除alfresco/bin下的Win32NetBIOS.dll(我本機(jī)是32位XP系統(tǒng),64位的對(duì)應(yīng)Win32NetBIOSx64.dll),啟動(dòng)alfresco/alf_start.bat時(shí)會(huì)出現(xiàn)下面錯(cuò)誤:
10:38:11,046 INFO? [repo.module.ModuleServiceImpl] Found 0 module(s).
java.lang.UnsatisfiedLinkError:
no Win32NetBIOS
in
java.library.path
?
出現(xiàn)這種錯(cuò)誤是因?yàn)閯h除了Win32NetBIOS.dll,查看alfresco/alfresco.bat,可以看到:
set PATH=%ALF_HOME%bin;%PATH%
在啟動(dòng)alfresco/alfresco.bat時(shí)java.library.path也會(huì)使用PATH中的路徑(alfresco/bin)去尋找相應(yīng)的Win32NetBIOS.dll,如果找不到,就會(huì)報(bào)上面的錯(cuò)誤。
?
注1:
新建一個(gè)JAVA類,在其中調(diào)用System.out.println(System.getProperty("java.library.path"));
可以得到java.library.path的值。
下面是我本機(jī)得到的結(jié)果:
C:\Java\jdk1.5.0_04\bin;
.;C:\WINDOWS\system32;C:\WINDOWS;C:\Java\jdk1.5.0_04\bin;D:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;E:\apache-ant-1.6.3\bin;E:\maven-1.0.2\bin;D:\mysql-5.0.45-win32\bin;C:\Program Files\OpenSSH\bin;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\Subversion\bin
?
觀察上面的java.library.path的值,可以看到它大概包括了三部分,即windows系統(tǒng)環(huán)境變量中PATH + JAVA_HOME/bin + 系統(tǒng)路徑(.;C:\WINDOWS\system32;C:\WINDOWS;)
?
注2:
為了不依賴于alfresco/bin/Win32NetBIOS.dll這個(gè)路徑(如果你下載不是
alfresco-community-tomcat-2.1.0.zip
這種內(nèi)嵌tomcat的版本,而是一個(gè)單獨(dú)的
alfresco-community-war-2.1.0.zip
,這點(diǎn)會(huì)非常有用),你可以把Win32NetBIOS.dll拷貝到C:\Java\jdk1.5.0_04\bin或C:\WINDOWS\system32路徑中,刪除alfresco/bin/Win32NetBIOS.dll依然可以使用alfresco/alf_start.bat正常啟動(dòng)alfresco。
?
⑺
下面出錯(cuò)信息:
org.alfresco.error.AlfrescoRuntimeException: Ensure that the 'dir.root' property
?is pointing to the correct data location.
?
alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco
下的repository.properties文件中:
# Change the failure behaviour of the configuration checker
system.bootstrap.config_check.strict=true
改為:
# Change the failure behaviour of the configuration checker
system.bootstrap.config_check.strict=false
?
16:30:32,546 ERROR [ConfigurationChecker] CONTENT INTEGRITY ERROR: Indexes not found for 5 stores.
alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco
下的repository.properties文件中:
# The index recovery mode (NONE, VALIDATE, AUTO, FULL)
index.recovery.mode=VALIDATE
?
改為:
# The index recovery mode (NONE, VALIDATE, AUTO, FULL)
index.recovery.mode=FULL
可以重新創(chuàng)建索引。
?
?
2
.
alfresco
默認(rèn)數(shù)據(jù)庫HSQL database
①
alfresco默認(rèn)使用的數(shù)據(jù)庫為HSQL database,可在alfresco\tomcat\shared\classes\alfresco\extension中找到兩個(gè)與數(shù)據(jù)庫定義相關(guān)的文件custom-hibernate-dialect.properties和custom-repository.properties(還可以定義一些其它系統(tǒng)配置),其中
custom-hibernate-dialect.properties
:
hibernate.dialect=org.hibernate.dialect.HSQLDialect
?
custom-repository.properties
:
db.driver=org.hsqldb.jdbcDriver
db.url=jdbc:hsqldb:file:alf_data/hsql_data/alfresco;ifexists=true;shutdown=true;
?
這兩個(gè)文件是在alfresco\tomcat\shared\classes\alfresco\extension\custom-repository-context.xml中加載的。
?
②
在alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco下有另外的一個(gè)文件repository.properties,這個(gè)文件與上面的custom-repository.properties相對(duì)應(yīng),如果在兩個(gè)properties文件中定義了相同的key/value資源,在加載文件中的資源時(shí),custom-repository.properties會(huì)覆蓋repository.properties中的(實(shí)際上是map中value被覆蓋),這與兩者的加載順序有關(guān):
alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\application-context.xml
中先后加載(見下)。
<import resource="classpath:alfresco/core-services-context.xml" />
<import resource="classpath*:alfresco/extension/*-context.xml"/>
?
repository.properties
與custom-repository.properties分別在core-services-context.xml與custom-repository-context.xml中指定
?
注
:
查看repository.properties文件,可以看到
db.username=alfresco
db.password=alfresco
這與上面1.- ② - ⑶ 中使用alfresco.script創(chuàng)建HSQL數(shù)據(jù)庫用戶的sql語句是對(duì)應(yīng)的。
?
?
3
.
把hsql轉(zhuǎn)為mysql(使用幫助也可參考alfresco/
README_mysql.txt
)
①
alfresco
使用mysql數(shù)據(jù)庫
⑴
實(shí)際發(fā)布的時(shí)候一般不建議使用HSQL database這種文件型數(shù)據(jù)庫。
啟動(dòng)alf_start.bat可以看到控制臺(tái)有一行提示:
11:10:57,062 INFO? [domain.schema.SchemaBootstrap] Alfresco is using the HSQL de
fault database. Please only use this while evaluating Alfresco, it is
NOT recomm
ended
for production or deployment!
?
使用mysql數(shù)據(jù)庫前清空文件夾:alfresco/alf_data(其中alfresco/alf_data/hsql_data文件夾可以刪除,因?yàn)檫@時(shí)已經(jīng)用不到HSQL數(shù)據(jù)庫了),alfresco/tomcat/temp, alfresco/tomcat/work。
?
⑵
打開alfresco/extras/databases/mysql下的db_setup.sql,可以看到:
create database alfresco;
grant all on alfresco.* to 'alfresco'@'localhost' identified by 'alfresco' with grant option;
grant all on alfresco.* to 'alfresco'@'localhost.localdomain' identified by 'alfresco' with grant option;
上面創(chuàng)建了alfresco數(shù)據(jù)庫,并創(chuàng)建用戶名alfresco密碼alfresco,分配管理權(quán)限。
?
為確保國際化,統(tǒng)一使用UTF8編碼(alfresco/
README_mysql.txt
中也有提到),db_setup.sql修改為:
create database alfresco DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
grant all on alfresco.* to 'alfresco'@'localhost' identified by 'alfresco' with grant option;
grant all on alfresco.* to 'alfresco'@'localhost.localdomain' identified by 'alfresco' with grant option;
?
運(yùn)行alfresco/extras/databases/mysql/db_setup.bat,即可創(chuàng)建mysql數(shù)據(jù)庫。
?
②
alfresco\tomcat\shared\classes\alfresco\extension
中找到兩個(gè)與數(shù)據(jù)庫定義相關(guān)的文件custom-hibernate-dialect.properties和custom-repository.properties(還可以定義一些其它系統(tǒng)配置),其中
custom-hibernate-dialect.properties
:
hibernate.dialect=org.hibernate.dialect.HSQLDialect
?
custom-repository.properties
:
db.driver=org.hsqldb.jdbcDriver
db.url=jdbc:hsqldb:file:alf_data/hsql_data/alfresco;ifexists=true;shutdown=true;
修改為
custom-hibernate-dialect.properties
:
#hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
?
custom-repository.properties
:
#db.driver=org.hsqldb.jdbcDriver
#db.url=jdbc:hsqldb:file:alf_data/hsql_data/alfresco;ifexists=true;shutdown=true;
db.driver=org.gjt.mm.mysql.Driver
db.url=jdbc:mysql://localhost/alfresco
?
默認(rèn)的alfresco數(shù)據(jù)庫用戶名和密碼位于alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco下的repository.properties文件中(可參考2.- ② -注)。
?
?
③
啟動(dòng)alfresco/alf_start.bat,可以看到在alfresco/alf_data下生成4個(gè)文件夾:lucene-indexes/contentstore.deleted/contentstore/audit.contentstore。
?
alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco
下的repository.properties文件中定義了這些初始化參數(shù):
# Directory configuration
dir.root=./alf_data
dir.contentstore=${dir.root}/contentstore
dir.contentstore.deleted=${dir.root}/contentstore.deleted
dir.auditcontentstore=${dir.root}/audit.contentstore
?
# The location for lucene index files
dir.indexes=${dir.root}/lucene-indexes
# The location for lucene index locks
dir.indexes.lock=${dir.indexes}/locks
?
注:
alfresco
數(shù)據(jù)庫中保存的是一些數(shù)據(jù)庫關(guān)系(以及JBPM的一些表),比如預(yù)定義的permission/node/access_control等,而數(shù)據(jù)(data)和內(nèi)容(content)保存在alfresco/alf_data文件夾下。
?
?
4
.
使用mysql數(shù)據(jù)庫亂碼問題
①
如上3.轉(zhuǎn)換為mysql數(shù)據(jù)庫后,訪問http://localhost:8080/alfresco/如果語言選擇中文,進(jìn)入系統(tǒng)后一些地方會(huì)出現(xiàn)中文亂碼。
我使用的是mysql-5.0.45-win32解壓版數(shù)據(jù)庫,如果出現(xiàn)亂碼,首先確保你數(shù)據(jù)庫編碼設(shè)置正確,使用show variables like 'chara%';查看你數(shù)據(jù)庫編碼,比較重要的有四個(gè)編碼:
character_set_client
:
客戶端字符集(應(yīng)用程序客戶端使用的字符集)。
character_set_connection
:
連接字符集。
character_set_results
:
指的是使用sql查詢處理以后返回結(jié)果使用的字符集。
character_set_database
:
指的數(shù)據(jù)庫表中物理存儲(chǔ)使用的字符集。
?
因?yàn)?span lang="EN-US">alfresco代碼使用的是utf8格式,所以在使用
create database alfresco DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
創(chuàng)建數(shù)據(jù)庫之前,首先設(shè)置mysql數(shù)據(jù)庫編碼,這樣在啟動(dòng)alfresco/alf_start.bat初始化mysql數(shù)據(jù)庫時(shí)(創(chuàng)建alfresco表和數(shù)據(jù))時(shí),才能保證表和數(shù)據(jù)格式的正確。
set character_set_database='gbk';?
(設(shè)置為gbk可以在查看表數(shù)據(jù)時(shí)顯示中文數(shù)據(jù))
set names 'utf8';
(設(shè)置character_set_client/ character_set_connection/ character_set_results字符集)
?
alfresco\tomcat\shared\classes\alfresco\extension
中
custom-repository.properties
:
db.url=jdbc:mysql://localhost/alfresco
修改為
custom-repository.properties
:
db.url=jdbc:mysql://localhost/alfresco?characterEncoding=gbk&useUnicode=true
?
?
附1:
在安裝使用過程中如果出現(xiàn)一些錯(cuò)誤或者需要一些幫助,不妨到下面網(wǎng)站找些有用的信息參考一下:
Alfresco
官方wiki
http://wiki.alfresco.com/wiki/Main_Page
Alfresco
官方forums
http://forums.alfresco.com/
Alfresco
官方help
http://www.alfresco.org/help/webclient/
?
附2:
從官方網(wǎng)站(http://www.alfresco.com/products/ecm/specifications/)可以看到它支持的一些
Technical Specifications
,如
支持操的作系統(tǒng)
Linux
MacOS
Unix
Windows
?
支持的瀏覽器
Firefox
Internet Explorer
?
支持
的
數(shù)據(jù)庫
Any Database Supported by Hibernate including:
MySQL
Oracle
?
使用的技術(shù)
Java
Spring? Aspect-Oriented Framework
ACEGI – Aspect-Oriented Security Framework
MyFaces? JSF Implementation
Hibernate? ORM Persistence
Lucene? Text Search Engine
JLAN
POI File Format Conversion
PDFBox – PDF Conversion
OpenOffice
jBPM
Rhino JavaScript engine
?
附3:
alfresco
的源代碼(
alfresco-community-sdk-2.1.0.zip
)下載地址為:http://sourceforge.net/project/showfiles.php?group_id=143373,不知道什么原因,下載SDK之后無法進(jìn)行編譯,去掉兩個(gè)出錯(cuò)文件然后編譯成功,不過啟動(dòng)alfresco會(huì)報(bào)錯(cuò)。
?
最好的辦法是從SVN上下載它的SDK,下載地址為:http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/
安裝SVN(最新版本為
svn-1.4.5-setup.exe
,下載地址http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91)之后,可以通過
svn co http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD
命令下載源代碼。
?
詳細(xì)SVN下載方式也可參考
Alfresco
官方wiki
http://wiki.alfresco.com/wiki/Alfresco_SVN_Development_Environment
?
Alfresco2.1
下載和安裝
.pdf
下載地址:
Alfresco2.1
下載和安裝
.rar
?
版權(quán)所有:(xiaodaoxiaodao)藍(lán)小刀
??
xiaodaoxiaodao@gmail.com
?