|
Hi everybody, I'm new in grails and when I try to create a new domain model, I have exception ... I created a new grails application (called 'shopbazar') with a new domain model: package shopbazar class ArticleCategorie { String Label double TVA @Override String toString() { "${Label} (${TVA}%)" } } And everything works fine until I add the following code in my class, static constraints = { Label(blank: false) } or any other constraint, on any field (I tried to add some other fields with others constraints) The springtoolsuite tries to compile, but I receive the following errors: | Loading Grails 2.0.1 | Configuring classpath. | Environment set to development..... | Packaging Grails application..... | Compiling 2 source files..... | Downloading: plugins-list.xml. | Running Grails application | Error 2012-04-03 01:21:35,982 [pool-7-thread-1] ERROR context.GrailsContextLoader - Error executing bootstraps: Error creating bean with name 'transactionManagerPostProcessor': 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': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Failed to get field class java.lang.String.Label Message: Error creating bean with name 'transactionManagerPostProcessor': 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': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Failed to get field class java.lang.String.Label Line | Method ->> 303 | innerRun in java.util.concurrent.FutureTask$Sync - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 138 | run in java.util.concurrent.FutureTask | 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker | 908 | run in '' ^ 662 | run . . in java.lang.Thread Caused by 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': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Failed to get field class java.lang.String.Label ->> 303 | innerRun in java.util.concurrent.FutureTask$Sync - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 138 | run in java.util.concurrent.FutureTask | 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker | 908 | run in '' ^ 662 | run . . in java.lang.Thread Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Failed to get field class java.lang.String.Label ->> 303 | innerRun in java.util.concurrent.FutureTask$Sync - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 138 | run in java.util.concurrent.FutureTask | 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker | 908 | run in '' ^ 662 | run . . in java.lang.Thread Caused by IllegalStateException: Failed to get field class java.lang.String.Label ->> 15 | doCall in shopbazar.ArticleCategorie$__clinit__closure1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 303 | innerRun in java.util.concurrent.FutureTask$Sync | 138 | run . . in java.util.concurrent.FutureTask | 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker | 908 | run . . in '' ^ 662 | run in java.lang.Thread Caused by IllegalArgumentException: Can not set java.lang.String field shopbazar.ArticleCategorie.Label to java.lang.Class ->> 15 | doCall in shopbazar.ArticleCategorie$__clinit__closure1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 303 | innerRun in java.util.concurrent.FutureTask$Sync | 138 | run . . in java.util.concurrent.FutureTask | 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker | 908 | run . . in '' ^ 662 | run in java.lang.Thread I run with windows 7 64 bits, JDK 6 64 bits (I tried also with JDK 7 64 bits, it's the same result) Thank you for your help Hugo |
|
I would guess a naming convention problem by the exception message:
"java.lang.IllegalStateException: Failed to get field class java.lang.String.Label" Try something like: String label With a smallcaps "L" Regards. Alexandre Jacques On Mon, Apr 2, 2012 at 8:34 PM, Terelle Hugo <[hidden email]> wrote: > Hi everybody, > > I'm new in grails and when I try to create a new domain model, I have > exception ... > I created a new grails application (called 'shopbazar') with a new domain > model: > > package shopbazar > > class ArticleCategorie { > String Label > double TVA > > @Override > String toString() { > "${Label} (${TVA}%)" > } > } > > And everything works fine until I add the following code in my class, > > static constraints = { > Label(blank: false) > } > > or any other constraint, on any field (I tried to add some other fields with > others constraints) > > > The springtoolsuite tries to compile, but I receive the following errors: > > > | Loading Grails 2.0.1 > | Configuring classpath. > | Environment set to development..... > | Packaging Grails application..... > | Compiling 2 source files..... > | Downloading: plugins-list.xml. > | Running Grails application > | Error 2012-04-03 01:21:35,982 [pool-7-thread-1] ERROR > context.GrailsContextLoader - Error executing bootstraps: Error creating > bean with name 'transactionManagerPostProcessor': 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': Invocation of init method failed; > nested exception is java.lang.IllegalStateException: Failed to get field > class java.lang.String.Label > Message: Error creating bean with name 'transactionManagerPostProcessor': > 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': Invocation of init method failed; > nested exception is java.lang.IllegalStateException: Failed to get field > class java.lang.String.Label > Line | Method > ->> 303 | innerRun in java.util.concurrent.FutureTask$Sync > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > | 138 | run in java.util.concurrent.FutureTask > | 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker > | 908 | run in '' > ^ 662 | run . . in java.lang.Thread > Caused by 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': Invocation of init method failed; nested > exception is java.lang.IllegalStateException: Failed to get field class > java.lang.String.Label > ->> 303 | innerRun in java.util.concurrent.FutureTask$Sync > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > | 138 | run in java.util.concurrent.FutureTask > | 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker > | 908 | run in '' > ^ 662 | run . . in java.lang.Thread > Caused by BeanCreationException: Error creating bean with name > 'sessionFactory': Invocation of init method failed; nested exception is > java.lang.IllegalStateException: Failed to get field class > java.lang.String.Label > ->> 303 | innerRun in java.util.concurrent.FutureTask$Sync > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > | 138 | run in java.util.concurrent.FutureTask > | 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker > | 908 | run in '' > ^ 662 | run . . in java.lang.Thread > Caused by IllegalStateException: Failed to get field class > java.lang.String.Label > ->> 15 | doCall in shopbazar.ArticleCategorie$__clinit__closure1 > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > | 303 | innerRun in java.util.concurrent.FutureTask$Sync > | 138 | run . . in java.util.concurrent.FutureTask > | 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker > | 908 | run . . in '' > ^ 662 | run in java.lang.Thread > Caused by IllegalArgumentException: Can not set java.lang.String field > shopbazar.ArticleCategorie.Label to java.lang.Class > ->> 15 | doCall in shopbazar.ArticleCategorie$__clinit__closure1 > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > | 303 | innerRun in java.util.concurrent.FutureTask$Sync > | 138 | run . . in java.util.concurrent.FutureTask > | 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker > | 908 | run . . in '' > ^ 662 | run in java.lang.Thread > > > > > I run with windows 7 64 bits, JDK 6 64 bits (I tried also with JDK 7 64 > bits, it's the same result) > > > Thank you for your help > Hugo > > > > > > > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by hugoterelle
Error messages are not always clear. From what I see there is unhappiness with your BootStrap.groovy. Did you try to use any classes in BootStrap.groovy that you didn't import first?
|
|
In reply to this post by Alexandre Jacques
Agree with Alexandre on this one. But if that doesn't work, try prefixing your Label references with "this.Label"
On Tuesday, April 3, 2012, Alexandre Jacques wrote: I would guess a naming convention problem by the exception message: |
|
Hi all,
I didn't touch the bootstap.groovy I tried the little "l" for the 'label' and it works... But I don't understand why it doesn't work for the 'L' ... Do you have some explanations? Thank you all for your answers, Hugo |
|
On 03/04/2012 09:52, hugoterelle wrote:
> Hi all, > > I didn't touch the bootstap.groovy > I tried the little "l" for the 'label' and it works... But I don't > understand why it doesn't work for the 'L' ... > Do you have some explanations? There are many places in Grails that assume you are following the usual JavaBean conventions where property names are lowerCamelCase and class names are UpperCamelCase, and some of the conversions between property names, getter/setter names etc. may break down if you don't stick to this. Ian -- Ian Roberts | Department of Computer Science [hidden email] | University of Sheffield, UK --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Ok Ian, I will follow the standards
Thank you all!!!! |
| Powered by Nabble | Edit this page |
