Learn, Share, Build

209
October 02, 2017, at 04:36 AM

I'm about start with a web application project and am trying to integrate Mysql into grails 3. All of the online tutorials show as to change the DataSource file which does not currently ( theres Application.yml ). I tried changing the Application.yml as given in the official documentation, but it gives me a big error. Its a new project and has no other changes to it. I've used grails 2.4 previously, it was really easy with that and now I'm thinking of changing back.

Change:

dataSource :
pooled : true
dbCreate : "update"
url : "jdbc:mysql://localhost:3306/my_database"
driverClassName : "com.mysql.jdbc.Driver"
dialect : org.hibernate.dialect.MySQL5MyISAMDialect
username : "username"
password : "password"
properties :
   jmxEnabled : true
   initialSize : 5
   maxActive : 50
   minIdle : 5
   maxIdle : 25
   maxWait : 10000
   maxAge : 10 * 60000
   timeBetweenEvictionRunsMillis : 5000
   minEvictableIdleTimeMillis : 60000
   validationQuery : "SELECT 1"
   validationQueryTimeout : 3
   validationInterval : 15000
   testOnBorrow : true
   testWhileIdle : true
   testOnReturn : false
   jdbcInterceptors : "ConnectionState;StatementCache(max=200)"
   defaultTransactionIsolation : 
java.sql.Connection.TRANSACTION_READ_COMMITTED

the error I get:

/usr/lib/jvm/java-8-oracle/bin/java -XX:+TieredCompilation -
XX:TieredStopAtLevel=1 -XX:CICompilerCount=3 -Dfile.encoding=UTF-8 -
classpath /home/nischit/.gradle/caches/modules-2/files-
2.1/org.grails/grails-
shell/3.2.10/c6b000bbb8ac369a9be062f08e8a0a8d3f85705/grails-shell-            
3.2.10.jar:/home/nischit/.gradle/caches/modules-2/files-
2.1/org.slf4j/slf4j-
simple/1.7.25/8dacf9514f0c707cbbcdd6fd699e8940d42fb54e/slf4j-simple-
1.7.25.jar:/home/nischit/.gradle/caches/modules-2/files-
2.1/org.codehaus.plexus/plexus-component-api/1.0-alpha-
33/7d9560effcadf867937ac6885d0d1045ea98ab59/plexus-component-api-1.0-
alpha-33.jar:/home/nischit/.gradle/caches/modules-2/files

Running application...
2017-10-02 01:42:14.120 ERROR --- [ost-startStop-1] 
o.s.b.c.embedded.tomcat.TomcatStarter    : Error starting Tomcat 
context. Exception: 
org.springframework.beans.factory.BeanCreationException. Message: 
Error creating bean with name 'grailsCacheFilter': Cannot create 
inner bean '(inner bean)#17d4fdc1' of type
[grails.plugin.cache.web.filter.
simple.MemoryPageFragmentCachingFilter] 
while setting bean property 'filter'; nested exception is 
org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name '(inner bean)#17d4fdc1': Unsatisfied 
dependency expressed through method 'setUrlMappingsHandlerMapping' 
parameter 0; nested exception is 
org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'urlMappingsHandlerMapping': 
Unsatisfied dependency expressed through method 
'setWebRequestInterceptors' parameter 0; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'openSessionInViewInterceptor': Cannot 
resolve reference to bean 'hibernateDatastore' while setting bean 
property 'hibernateDatastore'; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'hibernateDatastore': Bean instantiation via 
constructor failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to 
instantiate [org.grails.orm.hibernate.HibernateDatastore]: 
Constructor threw exception; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'dataSource': Cannot resolve reference to 
bean 'dataSourceLazy' while setting constructor argument; nested 
exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'dataSourceLazy': Cannot resolve 
reference to bean 'dataSourceUnproxied' while setting constructor 
argument; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
    at grails.boot.GrailsApp.run(GrailsApp.groovy:83)
    at grails.boot.GrailsApp.run(GrailsApp.groovy:388)
    at grails.boot.GrailsApp.run(GrailsApp.groovy:375)
    at grails.boot.GrailsApp$run.call(Unknown Source)
    at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.
defaultCall(CallSiteArray.java:48)
Caused by: org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'grailsCacheFilter': Cannot create 
inner bean '(inner bean)#17d4fdc1' of type 
[grails.plugin.cache.web.filter.simple.
MemoryPageFragmentCachingFilter] while setting bean property 
'filter'; nested exception is 
org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name '(inner bean)#17d4fdc1': Unsatisfied 
dependency expressed through method 'setUrlMappingsHandlerMapping' 
parameter 0; nested exception is 
org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'urlMappingsHandlerMapping': 
Unsatisfied dependency expressed through method 
'setWebRequestInterceptors' parameter 0; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'openSessionInViewInterceptor': Cannot 
resolve reference to bean 'hibernateDatastore' while setting bean 
property 'hibernateDatastore'; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'hibernateDatastore': Bean instantiation via 
constructor failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to 
instantiate [org.grails.orm.hibernate.HibernateDatastore]: 
Constructor threw exception; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'dataSource': Cannot resolve reference to 
bean 'dataSourceLazy' while setting constructor argument; nested 
exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'dataSourceLazy': Cannot resolve 
reference to bean 'dataSourceUnproxied' while setting constructor 
argument; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error c 
reating bean with name 'dataSourceUnproxied': Initialization of bean 
failed; nested exception is 
org.springframework.beans.TypeMismatchException: Failed to convert 
property value of type 'java.lang.String' to required type 'long' for 
property 'maxAge'; nested exception is 
java.lang.NumberFormatException: For input string: "10*60000"
at 
org.springframework.beans.factory.support.
BeanDefinitionValueResolver.resolveInnerBean
(BeanDefinitionValueResolver.java:313)
Caused by: 
org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name '(inner bean)#17d4fdc1': Unsatisfied 
dependency expressed through method 'setUrlMappingsHandlerMapping' 
parameter 0; nested exception is 
org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'urlMappingsHandlerMapping': 
Unsatisfied dependency expressed through method 
'setWebRequestInterceptors' parameter 0; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'openSessionInViewInterceptor': Cannot 
resolve reference to bean 'hibernateDatastore' while setting bean 
property 'hibernateDatastore'; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'hibernateDatastore': Bean instantiation via 
constructor failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to 
instantiate [org.grails.orm.hibernate.HibernateDatastore]: 
Constructor threw exception; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'dataSource': Cannot resolve reference to 
bean 'dataSourceLazy' while setting constructor argument; nested 
exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'dataSourceLazy': Cannot resolve 
reference to bean 'dataSourceUnproxied' while setting constructor 
argument; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'dataSourceUnproxied': Initialization of bean 
failed; nested exception is 
org.springframework.beans.TypeMismatchException: Failed to convert 
property value of type 'java.lang.String' to required type 'long' for 
property 'maxAge'; nested exception is 
java.lang.NumberFormatException: For input string: "10*60000"
at 
org.springframework.beans.factory.annotation.
AutowiredAnnotationBeanPostProcessor
$AutowiredMethodElement.inject
(AutowiredAnnotationBeanPostProcessor.java:667)
Caused by: 
org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'urlMappingsHandlerMapping': 
Unsatisfied dependency expressed through method 
'setWebRequestInterceptors' parameter 0; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'openSessionInViewInterceptor': Cannot 
resolve reference to bean 'hibernateDatastore' while setting bean 
property 'hibernateDatastore'; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'hibernateDatastore': Bean instantiation via 
constructor failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to 
instantiate [org.grails.orm.hibernate.HibernateDatastore]: 
Constructor threw exception; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'dataSource': Cannot resolve reference to 
bean 'dataSourceLazy' while setting constructor argument; nested 
exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'dataSourceLazy': Cannot resolve 
reference to bean 'dataSourceUnproxied' while setting constructor 
argument; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'dataSourceUnproxied': Initialization of bean 
failed; nested exception is 
org.springframework.beans.TypeMismatchException: Failed to convert 
property value of type 'java.lang.String' to required type 'long' for 
property 'maxAge'; nested exception is 
java.lang.NumberFormatException: For input string: "10*60000"
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bootRun'.
Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with 
non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info 
or --debug option to get more log output.
| Error Failed to start server (Use --stacktrace to see the full 
trace)
Answer 1

The problem is with the way you're trying to set the maxAge value on your data source:

Failed to convert property value of type 'java.lang.String' to required type 'long' for property 'maxAge'; nested exception is java.lang.NumberFormatException: For input string: "10*60000"

Try just setting a concrete value rather than a calculation.

Rent Charter Buses Company
READ ALSO
Learn, Share, Build

Learn, Share, Build

I have the below two separate statements querying the same table, in each case a select distinct is applied to a column and then another column summed

240
Learn, Share, Build

Learn, Share, Build

currently ,i do have two tables:

211
Learn, Share, Build

Learn, Share, Build

I have an application that needs to get the users details eg) first name from the database, however for each user i want to join the university they choose when registering and check if that university's ID matches against another external ID

253
Learn, Share, Build

Learn, Share, Build

This question already has an answer here:

245