Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grails 4: model type [four.Foo] is not of the correct type [four.Foo] #202

Closed
erichelgeson opened this issue Jan 14, 2019 · 2 comments
Closed
Milestone

Comments

@erichelgeson
Copy link
Contributor

Using Grails 4 master (jdk 11.0.1) with views 2.0.0.BUILD-SNAPSHOT I am seeing issues where the model doesnt think it's correct though it is. I've re-created the sample here: https://github.com/erichelgeson/grails4/compare/eric/gsonIssue

2019-01-14 16:22:24.807 ERROR --- [nio-8080-exec-1] o.g.web.errors.GrailsExceptionResolver   : IllegalArgumentException occurred when processing request: [GET] /foo/index.json
Model variable [foo] of with value [four.Foo : (unsaved)] type [four.Foo] is not of the correct type [four.Foo]. Stacktrace follows:

java.lang.reflect.InvocationTargetException: null
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker.invoke(DefaultGrailsControllerClass.java:211)
	at org.grails.core.DefaultGrailsControllerClass.invoke(DefaultGrailsControllerClass.java:188)
	at org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter.handle(UrlMappingsInfoHandlerAdapter.groovy:90)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
	at org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:77)
	at org.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalArgumentException: Model variable [foo] of with value [four.Foo : (unsaved)] type [four.Foo] is not of the correct type [four.Foo]
	at grails.views.WritableScriptTemplate.make(WritableScriptTemplate.groovy:138)
	at grails.plugin.json.view.template.JsonViewTemplate.make(JsonViewTemplate.groovy:19)
	at grails.views.mvc.GenericGroovyTemplateView.renderMergedOutputModel(GenericGroovyTemplateView.groovy:67)
	at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:316)
	at grails.views.mvc.renderer.DefaultViewRenderer.render(DefaultViewRenderer.groovy:117)
	at grails.artefact.controller.RestResponder$Trait$Helper.internalRespond(RestResponder.groovy:192)
	at grails.artefact.controller.RestResponder$Trait$Helper.respond(RestResponder.groovy:76)
	at four.FooController.index(FooController.groovy:8)
	... 15 common frames omitted
@erichelgeson erichelgeson changed the title Grails 4: Grails 4: model type [four.Foo] is not of the correct type [four.Foo] Jan 14, 2019
@graemerocher
Copy link
Member

Looks like GSON views is not using the right classloader

@ilopmar ilopmar added this to the grails-4.0.0 milestone Jan 15, 2019
@jameskleeh
Copy link
Collaborator

Fixed by 58a477f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants