Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Blocker
-
Resolution: Duplicate
-
Affects Version/s: 1.0.2
-
Fix Version/s: 1.0.3
-
Component/s: None
-
Labels:None
-
Environment:Microsoft Windows XP Professional (Service Pack 2), Pentium 4 CPU 3.20GHz 1GB RAM, Java SE JDK 1.6.0_05
Description
Self-relationship in a domain class breaks Grails.
Example:
1 - Create a new application:
grails create-app AutoBug
cd AutoBug
2 - Create a domain class:
grails create-domain-class Message
3 - Add some properties and a self-relationship to the domain class:
notepad grails-app\domain\Message.groovy
Message.groovy
// This code breaks Grails 1.0.2 class Message { String from String to String subject String content Message reply // <-- The problem is here! }
4 - Run the application:
grails run-app
5 - The result will be like this:
Stacktrace
...
2008-03-30 04:31:16.576::WARN: Failed startup of context org.mortbay.jetty.weba
pp.WebAppContext@1454f68
Unknown macro: {/AutoBug,D}
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' w
hile setting bean property 'sessionFactory'; nested exception is org.springframe
work.beans.factory.BeanCreationException: Error creating bean with name 'session
Factory': Invocation of init method failed; nested exception is java.lang.NullPo
interException
at java.security.AccessController.doPrivileged(Native Method)
at RunApp_groovy$_run_closure2_closure7.doCall(RunApp_groovy:68)
at RunApp_groovy$_run_closure2_closure7.doCall(RunApp_groovy)
at Init_groovy$_run_closure6.doCall(Init_groovy:128)
at RunApp_groovy$_run_closure2.doCall(RunApp_groovy:67)
at RunApp_groovy$_run_closure2.doCall(RunApp_groovy)
at RunApp_groovy$_run_closure1.doCall(RunApp_groovy:59)
at RunApp_groovy$_run_closure1.doCall(RunApp_groovy)
at gant.Gant.dispatch(Gant.groovy:271)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.processTargets(Gant.groovy:436)
at gant.Gant.processArgs(Gant.groovy:372)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'sessionFactory': Invocation of init method failed; nested exc
eption is java.lang.NullPointerException
at java.security.AccessController.doPrivileged(Native Method)
... 13 more
Caused by: java.lang.NullPointerException
... 14 more
2008-03-30 04:31:17.592::WARN: Nested in org.springframework.beans.factory.Bean
CreationException: Error creating bean with name 'transactionManager': Cannot re
solve reference to bean 'sessionFactory' while setting bean property 'sessionFac
tory'; nested exception is org.springframework.beans.factory.BeanCreationExcepti
on: Error creating bean with name 'sessionFactory': Invocation of init method fa
iled; nested exception is java.lang.NullPointerException:
java.lang.NullPointerException
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessController.doPrivileged(Native Method)
at RunApp_groovy$_run_closure2_closure7.doCall(RunApp_groovy:68)
at RunApp_groovy$_run_closure2_closure7.doCall(RunApp_groovy)
at Init_groovy$_run_closure6.doCall(Init_groovy:128)
at RunApp_groovy$_run_closure2.doCall(RunApp_groovy:67)
at RunApp_groovy$_run_closure2.doCall(RunApp_groovy)
at RunApp_groovy$_run_closure1.doCall(RunApp_groovy:59)
at RunApp_groovy$_run_closure1.doCall(RunApp_groovy)
at gant.Gant.dispatch(Gant.groovy:271)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.processTargets(Gant.groovy:436)
at gant.Gant.processArgs(Gant.groovy:372)
2008-03-30 04:31:18.496::INFO: Started SelectChannelConnector@0.0.0.0:8080
Server running. Browse to http://localhost:8080/AutoBug
The application works no more. If you try to access it, you get HTTP error 503.
Remove the self-relationship from Message.groovy and everything returns to normal:
notepad grails-app\domain\Message.groovy
Message.groovy
// This code works. class Message { String from String to String subject String content }
Attachments
Issue Links
| This issue duplicates: | ||||
| GRAILS-2689 | Domain classes with that have properties of the same class cause grails hibernate to crash on startup |
|
|
|
Grails 1.0.3 has the same problem, but version 1.0-RC4 is OK.