Issue Details (XML | Word | Printable)

Key: GRAILS-2762
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Graeme Rocher
Reporter: Jay Guidos
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Grails

Project will not load after upgrading

Created: 31/Mar/08 10:56 PM   Updated: 14/May/08 12:46 AM
Component/s: Persistence
Affects Version/s: 1.0.2
Fix Version/s: 1.0.3

Time Tracking:
Not Specified

Environment: Windows XP
Java 1.5


 Description  « Hide
This code worked fine in 1.0.1. I posted earlier today about getting strange exceptions after upgrading to 1.0.2, and it appears that GORM is having trouble with my base class. I rebuilt the project from scratch in a brand new 1.0.2 application to eliminate possibility of a bad upgrade.

I am building a run-time test environment, and my model is that I have run-time tests that are run by test plans. Test plans can be made up of sub-plans, to an arbitrary level. (Plans can be part of many plans too, but I haven't started on making that a many-2-many mapping yet).

I also use the same composite pattern adopted by JUnit, a la test suites, so both plans and tests are 'runnable' and inherit from a base class. Also, any AbstractTestRunnable can have a TestRun history, most notably recording what ran, who ran it and the result. TestRuns also are associated, in that I may want to issue a report of the results of all tests for a particular Plan. The hierarchy is attached to the end if this description.

In my bootstrap, I have this:

def plan = new Plan(name: 'First Plan', timeToRun: new Date(108, 3, 1))
def rtt = new RuntimeTest(name: "Hard Kill of TS1", scriptFile: "TSMDBHardKill")
plan.addToRunnables rtt

In 1.0.1 this worked great. In 1.0.2 I get an exception on the last line above:

2008-03-30 11:40:23.283::WARN: Failed startup of context org.mortbay.jetty.webapp.WebAppContext@c0d2d3{/BidsRTTE,c:\java\BidsRTTE/web-app}
org.codehaus.groovy.runtime.InvokerInvocationException: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'First Plan' with class 'Plan' to class 'java.util.Set'
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:92)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:946)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)
at groovy.lang.Closure.call(Closure.java:292)
at org.codehaus.groovy.grails.commons.DefaultGrailsBootstrapClass.callInit(DefaultGrailsBootstrapClass.java:43)
at org.codehaus.groovy.grails.web.context.GrailsConfigUtils.executeGrailsBootstraps(GrailsConfigUtils.java:64)
at org.codehaus.groovy.grails.web.context.GrailsContextLoader.createWebApplicationContext(GrailsContextLoader.java:51)

Here as promised is my Domain.

class AbstractTestRunnable { static hasMany = [ testRuns: TestRun, runnables: AbstractTestRunnable, runners: AbstractTestRunnable ] static mappedBy = [ testRuns: 'runner' ] String name List testRuns }

class RuntimeTest extends AbstractTestRunnable { String scriptFile }

class Plan extends AbstractTestRunnable{ Date timeToRun }

class TestRun {
static hasMany = [children: TestRun]
static belongsTo = TestRun
AbstractTestRunnable runnable
AbstractTestRunnable runner
List children
Date started
Date completed
boolean successful
String exception
static constraints = { exception(nullable: true) runnable(nullable: true) }



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Lee Butts added a comment - 14/May/08 12:46 AM
This issue was caused by the one-to-many inherited property (runnables in the example) in the child class believing that the other side of the relationship was the same property in the parent class.

I've added a better equals method to GrailsDomainClassProperty to hopefully avoid similar issues elsewhere and fixed up the isCandidateForOtherSide method that was causing the problem