2010-09-28 164 views
3

其實我在兩個tomcat實例上部署了我的grails應用程序。現在我遇到了一個問題。我的Quartz Job需要被聚類。Grails忽略hibernate.cfg.xml

我閱讀了插件文檔,發現可以將Quartz作業與數據庫結合使用。

因此,我必須在我的grails應用程序中創建一個hibernate映射('grails-app/conf/hibernate/hibernate.cfg.xml')。

<?xml version='1.0' encoding='UTF-8'?> 

<session-factory> 
    <mapping resource='Quartz.hbm.xml'/> 
</session-factory> 

然後,我還創建了一個Quartz.hbm.xml。這個爲Quartz Plugin創建表。

當我啓動我的應用程序時,好像hibernate.cfg.xml沒有被grails使用,並且沒有創建表。

我的想法是,問題是我的Spring數據源定義如下。

import org.apache.commons.dbcp.BasicDataSource 
import org.codehaus.groovy.grails.commons.ConfigurationHolder as CH 

// Place your Spring DSL code here 
beans = { 
    dataSource(BasicDataSource) { bean -> 
    bean.destroyMethod = 'close' 
    def ds = CH.config.dataSource 
    // required attributes 
    if(ds.driverClassName == "com.mysql.jdbc.Driver") { 
     url = ds.url 
     username = ds.username 
     password = ds.password 
     driverClassName = ds.driverClassName 
     // optional attributes 
     minEvictableIdleTimeMillis = 1000 * 60 * 30 
     timeBetweenEvictionRunsMillis = 1000 * 60 * 30 
     numTestsPerEvictionRun = 3 
     testOnBorrow = true 
     testWhileIdle = false 
     testOnReturn = false 
     initialSize = 2 
     minIdle = 1 
     maxIdle = 4 
     validationQuery = "SELECT NOW()" 
    } else { 
     url = ds.url 
     username = ds.username 
     password = ds.password 
     driverClassName = ds.driverClassName 
    } 
    } 
} 

現在我有從休眠日誌的輸出。似乎該文件將被解釋。但解析後發生了什麼?日誌中沒有例外。

2010-09-29 11:30:39,852 [main] DEBUG org.hibernate.util.DTDEntityResolver - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] 
2010-09-29 11:30:39,852 [main] DEBUG org.hibernate.util.DTDEntityResolver - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] 
2010-09-29 11:30:39,852 [main] DEBUG org.hibernate.util.DTDEntityResolver - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/ 
2010-09-29 11:30:39,852 [main] DEBUG org.hibernate.util.DTDEntityResolver - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/ 
2010-09-29 11:30:39,852 [main] DEBUG org.hibernate.util.DTDEntityResolver - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath 
2010-09-29 11:30:39,852 [main] DEBUG org.hibernate.util.DTDEntityResolver - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath 
2010-09-29 11:30:39,868 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration - null <- [email protected] [Attribute: name resource value "Quartz.hbm.xml"] 
2010-09-29 11:30:39,868 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration - null <- [email protected] [Attribute: name resource value "Quartz.hbm.xml"] 
2010-09-29 11:30:39,868 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : Quartz.hbm.xml 
2010-09-29 11:30:39,868 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : Quartz.hbm.xml 
2010-09-29 11:30:39,884 [main] DEBUG org.hibernate.util.DTDEntityResolver - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] 
2010-09-29 11:30:39,884 [main] DEBUG org.hibernate.util.DTDEntityResolver - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] 
2010-09-29 11:30:39,884 [main] DEBUG org.hibernate.util.DTDEntityResolver - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/ 
2010-09-29 11:30:39,884 [main] DEBUG org.hibernate.util.DTDEntityResolver - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/ 
2010-09-29 11:30:39,884 [main] DEBUG org.hibernate.util.DTDEntityResolver - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath 
2010-09-29 11:30:39,884 [main] DEBUG org.hibernate.util.DTDEntityResolver - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath 
2010-09-29 11:30:39,930 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null 
2010-09-29 11:30:39,930 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null 

任何想法?

+0

更多有關於你的信息 – Fabian 2010-09-29 09:42:21

回答

0

此行會搞亂我

然後,我還創建了一個Quartz.hbm.xml。 這個創建了 Quartz插件的表。

我相信你應該使用在你的數據庫特有的src/templates/sql目錄中提供給你的映射文件。

+0

對不起...這是正確的......我用mysql innodb映射文件 – Fabian 2010-09-29 07:27:59