views:

28

answers:

1

Actually I deployed my grails application on two tomcat instances. Now I ran into a problem. My Quartz Job needs to be clustered.

I read the plugin documentation and found a possibility to cluster the Quartz jobs in combination with the database.

Therefore I have to create a hibernate mapping ('grails-app/conf/hibernate/hibernate.cfg.xml') in my grails application.

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

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

Then I also created a Quartz.hbm.xml. This one creates the tables for the Quartz Plugin.

When I start up my application it seems like the hibernate.cfg.xml is not used by grails and the tables are not created.

My thought was that the problem is my Spring Datasource definition below.

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
    }
  }
}

Now I have the output from the hibernate log. It seems like the file will be interpreted. But what is going on after parsing? There is no exception in the log.

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 <- org.dom4j.tree.DefaultAttribute@1374ffd [Attribute: name resource value "Quartz.hbm.xml"]
2010-09-29 11:30:39,868 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration  - null <- org.dom4j.tree.DefaultAttribute@1374ffd [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

Any ideas?

A: 

this line is confusing to me

Then I also created a Quartz.hbm.xml. This one creates the tables for the Quartz Plugin.

I believe you should be using the mapping file provided to you in the src/templates/sql directory that is specific to your database.

Aaron Saunders
Oh sorry... That is correct... I used the mysql innodb mapping file
Fabian