Results 1 to 3 of 3

Thread: Abstract classes with Grails?

  1. #1

    Question Abstract classes with Grails?

    Hello,

    Is it possible to work with abstract classes in Grails, like in Java!? It seems to me that it's possible with Groovy, but with Grails I have a compilation problem when I declare a class as "abstract"...


    I am using the STS IDE for the development, when I save a class as "abstract", I have this message, before the server shuts down:

    Code:
    2011-02-06 18:24:48,793 [main] ERROR context.GrailsContextLoader  - 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': Invocation of init method failed; nested exception is java.lang.NullPointerException
    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 java.lang.NullPointerException
    	at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:212)
    I understand that we cannot generate a view for an abstract class... but then how to deal with abstract classes in Grails?

    I have a class A, and I want to say that it has as attributes a set of objects belonging to the abstract class B:

    Code:
    abstract class B {
    
        static constraints = {
        }	
    }
    
    class A {
    
        static constraints = {
        }	
    	static hasMany = [b:B]	
    }
    Is it possible with Grails!? I guess the answer is yes... well I hope... but how!?

    Thanks a lot.

  2. #2
    Join Date
    May 2009
    Location
    Vancouver
    Posts
    274

    Default

    Hi,

    Looks like you are hitting a variant of these issues which discuss the use of abstract classes:
    http://jira.codehaus.org/browse/GRAILS-5356
    http://jira.codehaus.org/browse/GRAILS-2583
    http://jira.codehaus.org/browse/GRAILS-6780

    there are probably others. Looks like grails 1.4 is intended to fix issues related to abstract classes. If you want more background, I recommend contacting the grails guys on their user list or in the grails forum: http://forum.springsource.org/forumdisplay.php?f=76

    cheers
    Andy
    ---
    Andy Clement
    SpringSource Tool Suite Team

  3. #3

    Thumbs up

    Hello, ans thank you for your answer.

    didn't know there is a GRAILS forum, I asked the question there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •