天天看點

Alfresco安裝後啟動異常處理

當出現下面這些出錯資訊時,隻要知道其出錯的原理,就很容易解決它。

⑴ org.alfresco.error.AlfrescoRuntimeException

不能直接在alfresco/tomcat/bin中運作startup.bat啟動Tomcat,會報錯:

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

[email protected]

Caused by:

org.alfresco.error.AlfrescoRuntimeException : Failure during rollback: org.alfres

co.repo.dictionary. DictionaryRepositoryBootstrap [email protected]

出錯是因為在alfresco/tomcat/bin中運作startup.bat啟動Tomcat,找不到相應的HSQL database的初始化資訊,可以參考下面的 ⑶仔細思考一下。

注1: 思考之後,你也許會嘗試把alfresco/alf_data/hsql_data這個檔案夾放到alfresco/tomcat/bin目錄中,然後再次運作startup.bat啟動Tomcat,你可以看一下運作結果會怎樣,這會幫助你了解alfresco初始化)。

注2: 如果你使用的是mysql資料庫,而mysql資料庫沒有運作mysqld啟動的話,也會報上面錯誤。

⑵ 在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版本

我本機版本檢視如下:

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中的幾行字,并沒有報錯,估計1.5 update 5到1.5 update 7中alfresco.bat中的幾行字也都是可以去掉的。

要想去掉上面alfresco.bat中的幾行字,必須下載下傳JDK的相應版本,下載下傳位址為:http://java.sun.com/products/archive/

⑶ alfresco/alf_data 下面有一個hsql_data檔案夾,存放的是一些HSQL database的初始化資訊,如果删除,也會報 ⑴中的錯

hsql_data 下面有兩個檔案

alfresco.properties :配置HSQL資料庫的一些初始化參數

alfresco.script :建立HSQL資料庫使用者的sql語句,預設建立兩個HSQL使用者(如下)。

CREATE USER SA PASSWORD ""

CREATE USER ALFRESCO PASSWORD "ALFRESCO"

注: 啟動alfresco時,如果HSQL資料庫被更改,alfresco.properties檔案會被更新,檔案中的modified=no更新為modified=yes

⑷ 清空初始化資訊和緩存(呵呵,當你進入http://localhost:8080/alfresco/進行了一些CRUD的操作之後就不要随便清空了,這會重新初始化你的HSQL資料庫)。

比較重要的一點是在出錯之後如果使用alf_start.bat重新啟動alfresco,最好要删除清空檔案夾:alfresco/alf_data(見注1),alfresco/tomcat/temp,否則很可能會報錯。

注1: 使用alf_start.bat重新啟動alfresco後,會在alfresco/alf_data下生成4個檔案夾:lucene-indexes/contentstore.deleted/contentstore/audit.contentstore

注2: 其中alfresco/alf_data/hsql_data檔案夾千萬不能删除,原因如 ⑶所述

注3: 另外,為徹底一點,你也可以清空alfresco/tomcat/work(tomcat下的/緩存檔案夾)。

⑸ 如果出現下面錯誤:

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關閉時不正常,可以再次運作alfresco/alf_stop.bat進行關閉。

⑹ 如果删除alfresco/bin下的Win32NetBIOS.dll(我本機是32位XP系統,64位的對應Win32NetBIOSx64.dll),啟動alfresco/alf_start.bat時會出現下面錯誤:

10:38:11,046 INFO [repo.module.ModuleServiceImpl] Found 0 module(s).

java.lang.UnsatisfiedLinkError: no Win32NetBIOS in java.library.path

出現這種錯誤是因為删除了Win32NetBIOS.dll,檢視alfresco/alfresco.bat,可以看到:

set PATH=%ALF_HOME%bin;%PATH%

在啟動alfresco/alfresco.bat時java.library.path也會使用PATH中的路徑(alfresco/bin)去尋找相應的Win32NetBIOS.dll,如果找不到,就會報上面的錯誤。

注1: 建立一個JAVA類,在其中調用System.out.println(System.getProperty("java.library.path"));

可以得到java.library.path的值。

下面是我本機得到的結果:

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系統環境變量中PATH + JAVA_HOME/bin + 系統路徑(.;C:\WINDOWS\system32;C:\WINDOWS;)

注2: 為了不依賴于alfresco/bin/Win32NetBIOS.dll這個路徑(如果你下載下傳不是 alfresco-community-tomcat-2.1.0.zip 這種内嵌tomcat的版本,而是一個單獨的 alfresco-community-war-2.1.0.zip ,這點會非常有用),你可以把Win32NetBIOS.dll拷貝到C:\Java\jdk1.5.0_04\bin或C:\WINDOWS\system32路徑中,删除alfresco/bin/Win32NetBIOS.dll依然可以使用alfresco/alf_start.bat正常啟動alfresco。

⑺ 下面出錯資訊:

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

可以重新建立索引。

2 . alfresco 預設資料庫HSQL database

① alfresco預設使用的資料庫為HSQL database,可在alfresco\tomcat\shared\classes\alfresco\extension中找到兩個與資料庫定義相關的檔案custom-hibernate-dialect.properties和custom-repository.properties(還可以定義一些其它系統配置),其中

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;

這兩個檔案是在alfresco\tomcat\shared\classes\alfresco\extension\custom-repository-context.xml中加載的。

② 在alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco下有另外的一個檔案repository.properties,這個檔案與上面的custom-repository.properties相對應,如果在兩個properties檔案中定義了相同的key/value資源,在加載檔案中的資源時,custom-repository.properties會覆寫repository.properties中的(實際上是map中value被覆寫),這與兩者的加載順序有關:

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建立HSQL資料庫使用者的sql語句是對應的。

3 . 把hsql轉為mysql(使用幫助也可參考alfresco/ README_mysql.txt )

① alfresco 使用mysql資料庫

⑴ 實際釋出的時候一般不建議使用HSQL database這種檔案型資料庫。

啟動alf_start.bat可以看到控制台有一行提示:

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資料庫前清空檔案夾:alfresco/alf_data(其中alfresco/alf_data/hsql_data檔案夾可以删除,因為這時已經用不到HSQL資料庫了),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;

上面建立了alfresco資料庫,并建立使用者名alfresco密碼alfresco,配置設定管理權限。

為確定國際化,統一使用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;

運作alfresco/extras/databases/mysql/db_setup.bat,即可建立mysql資料庫。

② alfresco\tomcat\shared\classes\alfresco\extension 中找到兩個與資料庫定義相關的檔案custom-hibernate-dialect.properties和custom-repository.properties(還可以定義一些其它系統配置),其中

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

預設的alfresco資料庫使用者名和密碼位于alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco下的repository.properties檔案中(可參考2.- ② -注)。

③ 啟動alfresco/alf_start.bat,可以看到在alfresco/alf_data下生成4個檔案夾:lucene-indexes/contentstore.deleted/contentstore/audit.contentstore。

alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco 下的repository.properties檔案中定義了這些初始化參數:

# 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 資料庫中儲存的是一些資料庫關系(以及JBPM的一些表),比如預定義的permission/node/access_control等,而資料(data)和内容(content)儲存在alfresco/alf_data檔案夾下。

4 . 使用mysql資料庫亂碼問題

① 如上3.轉換為mysql資料庫後,通路http://localhost:8080/alfresco/如果語言選擇中文,進入系統後一些地方會出現中文亂碼。

我使用的是mysql-5.0.45-win32解壓版資料庫,如果出現亂碼,首先確定你資料庫編碼設定正确,使用show variables like 'chara%';檢視你資料庫編碼,比較重要的有四個編碼:

character_set_client : 用戶端字元集(應用程式用戶端使用的字元集)。

character_set_connection : 連接配接字元集。

character_set_results : 指的是使用sql查詢處理以後傳回結果使用的字元集。

character_set_database : 指的資料庫表中實體存儲使用的字元集。

因為alfresco代碼使用的是utf8格式,是以在使用

create database alfresco DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;

建立資料庫之前,首先設定mysql資料庫編碼,這樣在啟動alfresco/alf_start.bat初始化mysql資料庫時(建立alfresco表和資料)時,才能保證表和資料格式的正确。

set character_set_database='gbk'; (設定為gbk可以在檢視表資料時顯示中文資料)

set names 'utf8'; (設定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