Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0-M1
-
Fix Version/s: 2.0.1
-
Component/s: Converters
-
Environment:Fedora 15 x86_64; Java JDK 1.6.0u24
Description
Error:
Cannot convert value of type [org.springframework.web.context.support.StandardServletEnvironment] to required type [com.thig.qardi.model.Environment] for property 'environment': no matching editors or conversion strategy found
Domain Classes:
class Server {
static belongsTo = Environment
static hasMany = [programs:ProgramType]
Environment environment
String name
String hostname
Integer port = 33335
static constraints = {
name nullable:false,blank:false
hostname nullable:false,blank:false
port nullable:false,blank:false
environment nullable: false
}
}
class Environment {
String name
static hasMany = [servers:Server]
static constraints = {
name nullable: false, blank: false, unique: true
}
}
Produces the error:
def server = new Server()
Graeme's response: "Hmm it seems Spring 3.1 defines a bean named environment which is the current Spring profile."
A seemingly related issue with a different error message is a field in a Domain object with the name of 'environment' (even if the class is not Environment).
class Author { } class Book { Author environment } class TestController { def index() { new Book() render "OK" } }fails with Class: java.lang.IllegalArgumentException Message: argument type mismatch
and this in the log
| Error 2011-12-20 13:48:13,868 ["http-bio-8080"-exec-1] ERROR errors.GrailsExceptionResolver - IllegalArgumentException occurred when processing request: [GET] /domain-issue/test argument type mismatch. Stacktrace follows: Message: argument type mismatch Line | Method ->> 8 | index in batchtool.TestControllerTook a while to track it down since it didn't mention environment at all in the error.