Quantcast

GroovyRuntimeException: Could not find matching constructor for:...

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

GroovyRuntimeException: Could not find matching constructor for:...

Emilio Suarez-4
I am having a weird problem... and and I new to Grails/Groovy... so I appologize is this has been answered elsewhere, but I just couldn't find any answers to my problem anywhere.

I have a simple Domain class with just Strings:

class CopanSystem {

    String systemName
    String systemVersion
    String ipAddress
    String modelNumber
    String serialNumber
    String softwareVersion
    String lastUpdated
    String customerID
    String location

    static hasMany = [racks:Rack, shelfs:Shelf]
}

and I create the controller and the views using "generate-all", and all is fine... start Grails and get the home page, click on the CopaSystemContoller... get the empty list, click on "New CopanSystem", fill in the fields with data (I tried numbers, text, etc.) and when clicking "Create" I get the error:

Message: Could not find matching constructor for: java.lang.String(java.lang.Long)
Caused by: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.lang.String(java.lang.Long)
Class: CopanSystemController
At Line: [77]

and line [77] is in the "save" block:
        if(!copanSystem.hasErrors() && copanSystem.save()) {

def save = {
        def copanSystem = new CopanSystem(params)
        println  copanSystem
        if(!copanSystem.hasErrors() && copanSystem.save()) {
            flash.message = "CopanSystem ${copanSystem.id} created"
            redirect(action:show,id:copanSystem.id)
        }
        else {
            render(view:'create',model:[copanSystem:copanSystem])
        }
    }
}

I have also tried adding the first record in the Bootstrap:

class BootStrap {

     def init = { servletContext ->
         new CopanSystem(systemName:"copan",systemVersion:"A12345",ipAddress:"10.10.1.101",modelNumber:"one",serialNumber:"123456ASDF",softwareVersion:"V1.0",lastUpdated:"10:05pm",customerID:"12345",location:"Longmont,CO").save()
    }
     def destroy = {
     }
}

And that also gives the error when Grails start...  any ideas?

thanks!

-emilio
--

-Emilio Suarez
http://emiliosuarez.com/blog.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: GroovyRuntimeException: Could not find matching constructor for:...

Emilio Suarez-4
Well,

I found the problem... so here it is for anybody else who might encounter the situation...

The problem was the usage of a variable named "lastUpdated" as a String. It looks like this one causes a conflict with one that Grails defines for each persistent class.  So I just removed the "lastUpdated" class and everything works now!!!

Hope this helps...

-emilio

On Thu, Jul 31, 2008 at 12:04 PM, Emilio Suarez <[hidden email]> wrote:
I am having a weird problem... and and I new to Grails/Groovy... so I appologize is this has been answered elsewhere, but I just couldn't find any answers to my problem anywhere.

I have a simple Domain class with just Strings:

class CopanSystem {

    String systemName
    String systemVersion
    String ipAddress
    String modelNumber
    String serialNumber
    String softwareVersion
    String lastUpdated
    String customerID
    String location

    static hasMany = [racks:Rack, shelfs:Shelf]
}

and I create the controller and the views using "generate-all", and all is fine... start Grails and get the home page, click on the CopaSystemContoller... get the empty list, click on "New CopanSystem", fill in the fields with data (I tried numbers, text, etc.) and when clicking "Create" I get the error:

Message: Could not find matching constructor for: java.lang.String(java.lang.Long)
Caused by: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.lang.String(java.lang.Long)
Class: CopanSystemController
At Line: [77]

and line [77] is in the "save" block:
        if(!copanSystem.hasErrors() && copanSystem.save()) {

def save = {
        def copanSystem = new CopanSystem(params)
        println  copanSystem
        if(!copanSystem.hasErrors() && copanSystem.save()) {
            flash.message = "CopanSystem ${copanSystem.id} created"
            redirect(action:show,id:copanSystem.id)
        }
        else {
            render(view:'create',model:[copanSystem:copanSystem])
        }
    }
}

I have also tried adding the first record in the Bootstrap:

class BootStrap {

     def init = { servletContext ->
         new CopanSystem(systemName:"copan",systemVersion:"A12345",ipAddress:"10.10.1.101",modelNumber:"one",serialNumber:"123456ASDF",softwareVersion:"V1.0",lastUpdated:"10:05pm",customerID:"12345",location:"Longmont,CO").save()
    }
     def destroy = {
     }
}

And that also gives the error when Grails start...  any ideas?

thanks!

-emilio
--

-Emilio Suarez
http://emiliosuarez.com/blog.html



--

-Emilio Suarez
http://emiliosuarez.com/blog.html
Loading...