I have a simple micronaut 3.0.3 application built with hibernate-gorm.
I get the following error when attempting to send a GET request like this http://localhost:8080/?commentId=1
Failed to convert argument [command] for value [null] due to: Specified value [1] is not of the correct type: class java.lang.Long (through reference chain: com.example.PostCommand[\"commentId\"])
This code worked in Micronaut version 2.5.12. I searched the migration guide about this but could not find any mentions about anything changing in this department.
PostCommand:
package com.example
import grails.gorm.annotation.Entity
import org.grails.datastore.gorm.GormEntity
@Entity
class PostCommand implements GormEntity<PostCommand> {
String title
String content
Long commentId
void setCommentId(Long commentId) {
this.commentId = commentId
}
void setCommentId(String commentId) {
this.commentId = Long.valueOf(commentId)
}
}
PostContoller:
package com.example
import io.micronaut.http.HttpRequest
import io.micronaut.http.HttpResponse
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
@Controller('/')
class PostController {
@Get('{?command*}')
HttpResponse search(HttpRequest request, PostCommand command){
HttpResponse.ok()
}
}
When removing all setters or just the setter for the string type, it works.
Here is a github link for anyone interested.
Any suggestions would be helpful.