Grails
  1. Grails
  2. GRAILS-8035

2-level inheritance (C extends B extends A) leads to crash

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0-RC1
    • Component/s: None
    • Labels:
      None
    • Environment:
      grails 2.0.0.M2
      Debian Wheezy 64bit
      Linux jonatan-ws 2.6.38-2-amd64 #1 SMP Thu Apr 7 04:28:07 UTC 2011 x86_64 GNU/Linux
    • Testcase included:
      yes

      Description

      2-level inheritance (C extends B extends A) leads to crash.

      This ticket is related to GRAILS-7794.

      I have 3 classes as follows:

      public abstract class HibernateDAO implements Serializable {
          // implementation of equals, hashCode, toString
      }
      
      @Entity
      @Table(name = "JOB_", schema = "CONFIGURATION",
      		uniqueConstraints = @UniqueConstraint(columnNames = { "CODE" }))
      @Inheritance(strategy = InheritanceType.JOINED)
      public class Job extends HibernateDAO {
      	private Integer id;
      	private String code;
      
      	@Id
      	@Column(name = "ID", nullable = false, precision = 8, scale = 0)
      	@GeneratedValue(generator = "SCHEDULE_SEQ", strategy = GenerationType.SEQUENCE)
      	@SequenceGenerator(name = "SCHEDULE_SEQ", sequenceName = "configuration.schedule_seq", allocationSize = 1)
      	public Integer getId() {
      		return id;
      	}
      
      	public void setId(Integer id) {
      		this.id = id;
      	}
      
      	@Column(name = "CODE", nullable = false, length = 64)
      	public String getCode() {
      		return code;
      	}
      
      	public void setCode(String code) {
      		this.code = code;
      	}
      }
      
      @Entity
      @Table(name = "INBOUND_COLLECTOR_JOB", schema = "CONFIGURATION")
      @PrimaryKeyJoinColumn(name = "JOB_ID")
      public class InboundCollectorJob extends Job {
      	private Boolean autoLaunchOutboundFlow;
      
      	@Column(name = "AUTO_LAUNCH_OUTBOUND_FLOW", nullable = false)
      	public Boolean getAutoLaunchOutboundFlow() {
      		return autoLaunchOutboundFlow;
      	}
      
      	public void setAutoLaunchOutboundFlow(Boolean autoLaunchOutboundFlow) {
      		this.autoLaunchOutboundFlow = autoLaunchOutboundFlow;
      	}
      }
      

      Both, Job and InboundCollectorJob are defined in hibernate.cfg.xml.

      During running of grails run-app I observe crash as shown below.
      After removing Job-HibernateDAO inheritance (changed to class Job implements Serializable) entities are processed without crash.

      grails> run-app 
      | Running Grails application
      servlet.DefaultGrailsApplicationAttributes ApplicationContext not found in org.codehaus.groovy.grails.APPLICATION_CONTEXT attribute of servlet context.
      context.GrailsContextLoader Error executing bootstraps: Error creating bean with name 'grailsDomainClassMappingContext': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.codehaus.groovy.grails.domain.GrailsDomainClassMappingContext]: Constructor threw exception; nested exception is java.lang.NullPointerException
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsDomainClassMappingContext': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.codehaus.groovy.grails.domain.GrailsDomainClassMappingContext]: Constructor threw exception; nested exception is java.lang.NullPointerException
      	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      	at java.lang.Thread.run(Thread.java:662)
      Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.codehaus.groovy.grails.domain.GrailsDomainClassMappingContext]: Constructor threw exception; nested exception is java.lang.NullPointerException
      	... 5 more
      Caused by: java.lang.NullPointerException
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:134)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	... 5 more
      [localhost].[/user-interface] 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 'grailsDomainClassMappingContext': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.codehaus.groovy.grails.domain.GrailsDomainClassMappingContext]: Constructor threw exception; nested exception is java.lang.NullPointerException
      	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      	at java.lang.Thread.run(Thread.java:662)
      Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.codehaus.groovy.grails.domain.GrailsDomainClassMappingContext]: Constructor threw exception; nested exception is java.lang.NullPointerException
      	... 5 more
      Caused by: java.lang.NullPointerException
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:134)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:132)
      	at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:117)
      	... 5 more
      core.StandardContext Error listenerStart
      

        Activity

        Hide
        Graeme Rocher added a comment -

        could you attach an example project?

        Show
        Graeme Rocher added a comment - could you attach an example project?
        Hide
        Jonatan Kazmierczak added a comment -

        Project attached as requested.
        After changing definition of Job to:
        Job implements Serializable
        app will start.
        BTW, sample for GPGORMJPA-15 want to create and attach tomorrow.

        Show
        Jonatan Kazmierczak added a comment - Project attached as requested. After changing definition of Job to: Job implements Serializable app will start. BTW, sample for GPGORMJPA-15 want to create and attach tomorrow.
        Hide
        Jonatan Kazmierczak added a comment -

        Attached file replaced - the previous zip didn't contain sources.

        Show
        Jonatan Kazmierczak added a comment - Attached file replaced - the previous zip didn't contain sources.
        Hide
        Jonatan Kazmierczak added a comment -

        Correct file attached once again with name TwoLevelInherit1a.zip - to avoid naming confusion.

        Show
        Jonatan Kazmierczak added a comment - Correct file attached once again with name TwoLevelInherit1a.zip - to avoid naming confusion.

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Jonatan Kazmierczak
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development