2011-08-31 9 views
5

Ho un'applicazione in produzione che ha avuto un timeout MySQL, quindi sto cercando di aggiungere parametri aggiuntivi all'origine dati per evitare questo. Nel 1.3.7 documentation dimostra che posso aggiungere un valore proprietà in questo modo:Grails DataSource Exception

properties { 
     maxActive = 50 
     maxIdle = 25 
     minIdle = 5 
     initialSize = 5 
     minEvictableIdleTimeMillis = 60000 
     timeBetweenEvictionRunsMillis = 60000 
     maxWait = 10000 
     validationQuery = "/* ping */" 
    } 

Tuttavia, quando aggiungo questo al mio datasource sviluppo ricevo il seguente errore:

ERROR Error executing bootstraps: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxActive' of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource]: Bean property 'maxActive' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxActive' of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource]: Bean property 'maxActive' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 
    at org.grails.tomcat.InlineExplodedTomcatServer.doStart(InlineExplodedTomcatServer.groovy:112) 
    at org.grails.tomcat.InlineExplodedTomcatServer$doStart.callCurrent(Unknown Source) 
    at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:97) 
    at grails.web.container.EmbeddableServer$start.call(Unknown Source) 
    at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy:158) 
    at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy) 
    at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280) 
    at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy) 
    at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:149) 
    at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy) 
    at _GrailsRun_groovy.runInline(_GrailsRun_groovy:116) 
    at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy) 
    at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59) 
    at RunApp$_run_closure1.doCall(RunApp:33) 
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381) 
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415) 
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy) 
    at gant.Gant.withBuildListeners(Gant.groovy:427) 
    at gant.Gant.this$2$withBuildListeners(Gant.groovy) 
    at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) 
    at gant.Gant.dispatch(Gant.groovy:415) 
    at gant.Gant.this$2$dispatch(Gant.groovy) 
    at gant.Gant.invokeMethod(Gant.groovy) 
    at gant.Gant.executeTargets(Gant.groovy:590) 
    at gant.Gant.executeTargets(Gant.groovy:589) 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxActive' of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource]: Bean property 'maxActive' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 
    ... 25 more 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxActive' of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource]: Bean property 'maxActive' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 
    ... 25 more 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxActive' of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource]: Bean property 'maxActive' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 
    ... 25 more 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxActive' of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource]: Bean property 'maxActive' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 
    ... 25 more 
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'maxActive' of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource]: Bean property 'maxActive' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 
    ... 25 more 

Quale potrebbe essere il problema ? Grazie.

+0

Perché si tratta di una nuova domanda e non di un commento su http://stackoverflow.com/questions/7260365/grails-and-mysql-connection-exception? –

+0

@Burt Beckwith - Sembrava un problema diverso. Il primo era "perché sto ricevendo questo errore?" e questo è più simile a "quando aggiungo questi parametri, perché sto ricevendo questo [altro] errore?" In ogni caso, conosci la risposta? :) – skaz

risposta

7

Lo stavo testando localmente, quindi ho inserito le proprietà nel mio blocco development. Tuttavia, non ho aggiunto pooled = true poiché di solito non è in questa sezione. Questo stava causando l'errore. Una volta aggiunta la dichiarazione di raggruppamento, tutto ha funzionato correttamente.

+1

Il diritto - il pooling è importante, altrimenti si rallentano le prestazioni aspettando ogni volta una nuova connessione. Potrebbe essere possibile impostare tali proprietà nel DriverManagerDataSource che si ottiene quando non si raggruppa, ma non esiste una convenzione di denominazione standard per tali proprietà, quindi sono diverse per ogni impl. Ad esempio, l'utilizzo di un pool C3P0 potrebbe anche fallire poiché alcuni nomi sono uguali ma altri no. –

+0

@Burt Beckwith - Il tuo aiuto è stato di valore inestimabile. Come puoi vedere, ho ancora molto da imparare. Hai una risorsa consigliata per Grails (libri, video, ecc.)? Ho letto la documentazione ma credo che mi manchi molto a cui devo tornare. In ogni caso, grazie per tutto il vostro aiuto fino ad ora (e probabilmente in futuro). – skaz

Problemi correlati