Acegi Plugin

Combining Grails Acegi plugin with declaring an Enum class in the domain class file causes MappingException

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: Grails-Acegi 0.5
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

I have tried to isolate the problem down to the failing line and here is what I gleaned on my system. BTW, this happens on Mac OSX and Fedora 10 for me (the only systems that I have).

The issue has to do with the presence of an Enum class in my Domain class file and with the Acegi Plugin. I do not know the details of Spring Security so I need some help to take this issue further.

The two scenarios I created is as follows:

1) Works: Domain class contains the Enum class as well, but NO Acegi plugin
2) Fails: Domain class contains the Enum class as well, and Acegi plugin is installed.
2) Works: Domain class does NOT contain the Enum class, and Acegi plugin is installed.

Also, enabling and disabling the security via the SecurityConfig.groovy does not make any difference.

Note that this problem occurs on Grails 1.1.1 as well as 1.2-M2 and 1.2-M3 (these are the only ones I have tried).

Also note that if I move the Enum class to a different file, this problem goes away (work around for me).

I am attaching two zip files. One with and one without Acegi for you to see the difference.

  • Tosh

===============================================================================

Welcome to Grails 1.2-M3 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /usr/local/grails-1.2-M3

Base Directory: /Users/tosh/MySoftware/Eclipse/grails-12M3/mappingException
Resolving dependencies...
Dependencies resolved in 937ms.
Running script /usr/local/grails-1.2-M3/scripts/RunApp.groovy
Environment set to development
[copy] Copied 9 empty directories to 5 empty directories under /Users/tosh/.grails/1.2-M3/projects/mappingException/resources
[copy] Copied 1 empty directory to 1 empty directory under /Users/tosh/.grails/1.2-M3/projects/mappingException/resources
[copy] Copied 2 empty directories to 2 empty directories under /Users/tosh/.grails/1.2-M3/projects/mappingException/resources
[mkdir] Created dir: /Users/tosh/MySoftware/Eclipse/grails-12M3/mappingException/target/classes
[groovyc] Compiling 38 source files to /Users/tosh/MySoftware/Eclipse/grails-12M3/mappingException/target/classes
Note: /Users/tosh/.grails/1.2-M3/projects/mappingException/plugins/acegi-0.5.2/src/java/org/codehaus/groovy/grails/plugins/springsecurity/ldap/GrailsLdapUser.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
[groovyc] Compiling 13 source files to /Users/tosh/MySoftware/Eclipse/grails-12M3/mappingException/target/classes
[mkdir] Created dir: /Users/tosh/.grails/1.2-M3/projects/mappingException/resources/grails-app/i18n
[native2ascii] Converting 12 files from /Users/tosh/MySoftware/Eclipse/grails-12M3/mappingException/grails-app/i18n to /Users/tosh/.grails/1.2-M3/projects/mappingException/resources/grails-app/i18n
[copy] Copying 1 file to /Users/tosh/MySoftware/Eclipse/grails-12M3/mappingException/target/classes
[copy] Copied 2 empty directories to 2 empty directories under /Users/tosh/.grails/1.2-M3/projects/mappingException/resources
Running Grails application..
[active=false] Spring Security not loaded
2009-10-05 17:08:47,299 [main] ERROR context.ContextLoader - Context initialization failed
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': Invocation of init method failed; nested exception is org.hibernate.MappingException: Type [null] is not a basic type or a domain class and cannot be mapped. Either specify a type within the [mapping] block or use a basic type (String, Integer etc.)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3961)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4456)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:515)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:708)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:252)
at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:115)
at grails.web.container.EmbeddableServer$start.call(Unknown Source)
at _GrailsRun_groovy$_run_closure5_closure11.doCall(_GrailsRun_groovy:155)
at _GrailsRun_groovy$_run_closure5_closure11.doCall(_GrailsRun_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:273)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:147)
at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
at _GrailsRun_groovy.runInline(_GrailsRun_groovy:113)
at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:57)
at RunApp$_run_closure1.doCall(RunApp.groovy:33)
at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:344)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:334)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.processTargets(Gant.groovy:495)
at gant.Gant.processTargets(Gant.groovy:480)
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': Invocation of init method failed; nested exception is org.hibernate.MappingException: Type [null] is not a basic type or a domain class and cannot be mapped. Either specify a type within the [mapping] block or use a basic type (String, Integer etc.)
... 32 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Type [null] is not a basic type or a domain class and cannot be mapped. Either specify a type within the [mapping] block or use a basic type (String, Integer etc.)
... 32 more
Caused by: org.hibernate.MappingException: Type [null] is not a basic type or a domain class and cannot be mapped. Either specify a type within the [mapping] block or use a basic type (String, Integer etc.)
... 32 more
2009-10-05 17:08:47,301 [main] ERROR [localhost].[/mappingException] - Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
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': Invocation of init method failed; nested exception is org.hibernate.MappingException: Type [null] is not a basic type or a domain class and cannot be mapped. Either specify a type within the [mapping] block or use a basic type (String, Integer etc.)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3961)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4456)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:515)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:708)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:252)
at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:115)
at grails.web.container.EmbeddableServer$start.call(Unknown Source)
at _GrailsRun_groovy$_run_closure5_closure11.doCall(_GrailsRun_groovy:155)
at _GrailsRun_groovy$_run_closure5_closure11.doCall(_GrailsRun_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:273)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:147)
at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
at _GrailsRun_groovy.runInline(_GrailsRun_groovy:113)
at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:57)
at RunApp$_run_closure1.doCall(RunApp.groovy:33)
at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:344)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:334)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.processTargets(Gant.groovy:495)
at gant.Gant.processTargets(Gant.groovy:480)
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': Invocation of init method failed; nested exception is org.hibernate.MappingException: Type [null] is not a basic type or a domain class and cannot be mapped. Either specify a type within the [mapping] block or use a basic type (String, Integer etc.)
... 32 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Type [null] is not a basic type or a domain class and cannot be mapped. Either specify a type within the [mapping] block or use a basic type (String, Integer etc.)
... 32 more
Caused by: org.hibernate.MappingException: Type [null] is not a basic type or a domain class and cannot be mapped. Either specify a type within the [mapping] block or use a basic type (String, Integer etc.)
... 32 more
2009-10-05 17:08:47,302 [main] ERROR core.StandardContext - Error listenerStart
2009-10-05 17:08:47,317 [main] ERROR core.StandardContext - Context [/mappingException] startup failed due to previous errors
Server running. Browse to http://localhost:8080/mappingException

Activity

Hide
Chris Brookes added a comment -

Another simliar error message that is caused by this problem is:

Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: DomainWithEnum, at table: other_domain_assoc, for columns: [org.hibernate.mapping.Column(domain_with_enum)]

This was only a problem for me when moving from Grails 1.2-M2 to 1.2-M3.
The workaround stated above also works for me.

Show
Chris Brookes added a comment - Another simliar error message that is caused by this problem is:
Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: DomainWithEnum, at table: other_domain_assoc, for columns: [org.hibernate.mapping.Column(domain_with_enum)]
This was only a problem for me when moving from Grails 1.2-M2 to 1.2-M3. The workaround stated above also works for me.
Hide
Ralf Bensmann added a comment - - edited

I get the same error as Chris, when running grails run-app with an empty database:

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': Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: [LProduct;, at table: company, for columns: [org.hibernate.mapping.Column(product)]

This error is confusing: there is no reference to an array of type Product at all in the domain class and I don't use an enum.

The workaround of deinstalling Acegi did not work for me. I use Grails 1.2.0-RC1.

-8<8<8<8<8<8<--

Sorry, the error message was misleading me to this issue. I had an reference to Product[] in a subclass of Company (instead of defining static hasMany...).

Show
Ralf Bensmann added a comment - - edited I get the same error as Chris, when running grails run-app with an empty database: 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': Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: [LProduct;, at table: company, for columns: [org.hibernate.mapping.Column(product)] This error is confusing: there is no reference to an array of type Product at all in the domain class and I don't use an enum. The workaround of deinstalling Acegi did not work for me. I use Grails 1.2.0-RC1. -8<8<8<8<8<8<-- Sorry, the error message was misleading me to this issue. I had an reference to Product[] in a subclass of Company (instead of defining static hasMany...).
Hide
Shawn Hamill added a comment - - edited

Just wanted to share my similar experience: (Please forgive me for using windows!)

I had a working grails 1.1.2 app on windows that used acegi 0.5.2.
I upgraded the app to grails 1.2.0.
I receive the exact same mapping exception on startup that the original reporter does.

I will attempt to resolve this issue by moving a nested enum outside of its class and report back later.

Update: Turns out there was a single domain class in our project that had a static enum defined inside of it. I moved the enum outside the scope of the class (but still in the same file) and the problem was resolved.

Show
Shawn Hamill added a comment - - edited Just wanted to share my similar experience: (Please forgive me for using windows!) I had a working grails 1.1.2 app on windows that used acegi 0.5.2. I upgraded the app to grails 1.2.0. I receive the exact same mapping exception on startup that the original reporter does. I will attempt to resolve this issue by moving a nested enum outside of its class and report back later. Update: Turns out there was a single domain class in our project that had a static enum defined inside of it. I moved the enum outside the scope of the class (but still in the same file) and the problem was resolved.
Hide
Burt Beckwith added a comment -

Just define the enum in src/groovy or src/java

Show
Burt Beckwith added a comment - Just define the enum in src/groovy or src/java

People

Vote (4)
Watch (5)

Dates

  • Created:
    Updated:
    Resolved: