Closed T00mm closed 5 years ago
Please check out the argument types in your template code. You should provide right key and form types in the template as in this sample.
Yes, I am using
@(key: Long, simpleForm: Form[Voeding])
and Voeding is a model
It also only happens when I go to the edit page, the create page works fine.
Please turn DEBUG logging for "play.utils.crud" package on and paste detailed logs here.
[info] play - database [default] connected at jdbc:h2:db/development
[debug] p.u.c.CRUDManager - initialize <-
[info] p.u.m.c.ClasspathScanningConverterRegistry - Converter:class java.lang.Integer : play.utils.meta.convert.IntegerConverter@47de2fa7
[info] p.u.m.c.ClasspathScanningConverterRegistry - Converter:class java.lang.Double : play.utils.meta.convert.DoubleConverter@6aa3821a
[info] p.u.m.c.ClasspathScanningConverterRegistry - Converter:class java.lang.Long : play.utils.meta.convert.LongConverter@12300a7b
[info] play - Application started (Dev)
[debug] p.u.c.RouterCrudController - editForm <- Voeding, 1
[debug] p.u.c.CRUDController - editForm() <-1
[debug] p.u.c.CRUDController - model : Simple [key=1, name=qsddqs]
[error] play - Cannot invoke the action, eventually got an error: java.lang.IllegalArgumentException: argument type mismatch
[error] application -
! @6i7a7k6gh - Internal server error, for (GET) [/app/Voeding/1/edit] ->
play.api.Application$$anon$1: Execution exception[[IllegalArgumentException: argument type mismatch]]
at play.api.Application$class.handleError(Application.scala:293) ~[na:na]
at play.api.DefaultApplication.handleError(Application.scala:399) [na:na]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:261) [na:na]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:261) [na:na]
at scala.Option.map(Option.scala:145) [na:na]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2.applyOrElse(PlayDefaultUpstreamHandler.scala:261) [na:na]
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_05]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_05]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_05]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_05]
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:191) ~[na:na]
at play.utils.crud.TemplateController.call(TemplateController.java:97) ~[na:na]
I think I have noticed the error
[debug] p.u.c.CRUDController - model : Simple [key=1, name=qsddqs]
But I am not sure how I could fix this?
:) Search for "Simple" in your code and replace with "Voeding". It's probably in your Controller class but may be more.
Yeah my controller class is just
package controllers;
import play.mvc.Controller;
import play.mvc.Result;
import play.api.i18n.*;
public class Application extends Controller {
public static Result index() {
return ok(views.html.index.render());
}
public static Result changeLanguage(String langCode) {
changeLang(langCode);
return ok(views.html.index.render());
}
}
routes is just
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
# Home page
GET / controllers.Application.index()
GET /language controllers.Application.changeLanguage(lang ?= "en")
# CRUD Controllers
-> /app play.crud.Routes
# REST API
-> /api play.rest.Routes
#Assets
GET /assets/*file controllers.Assets.at(path="/public", file)
For the rest, I can't find Simple anywhere.
Any other occurences of "Simple"? What about DAOs?
I don't think I have ever defined a DAO, also I have just refreshed and now I just get
[info] play - database [default] connected at jdbc:h2:db/development
[debug] p.u.c.CRUDManager - initialize <-
[info] p.u.m.c.ClasspathScanningConverterRegistry - Converter:class java.lang.Integer : play.utils.meta.convert.IntegerConverter@188f72bf
[info] p.u.m.c.ClasspathScanningConverterRegistry - Converter:class java.lang.Double : play.utils.meta.convert.DoubleConverter@79c64afd
[info] p.u.m.c.ClasspathScanningConverterRegistry - Converter:class java.lang.Long : play.utils.meta.convert.LongConverter@44d5aba3
[info] play - Application started (Dev)
[debug] p.u.c.RouterCrudController - editForm <- Voeding, 1
[debug] p.u.c.CRUDController - editForm() <-1
[debug] p.u.c.CRUDController - model : Voeding [key=1, name=qsddqs]
[error] play - Cannot invoke the action, eventually got an error: java.lang.IllegalArgumentException: argument type mismatch
[error] application -
! @6i7aakn1p - Internal server error, for (GET) [/app/Voeding/1/edit] ->
play.api.Application$$anon$1: Execution exception[[IllegalArgumentException: argument type mismatch]]
at play.api.Application$class.handleError(Application.scala:293) ~[na:na]
at play.api.DefaultApplication.handleError(Application.scala:399) [na:na]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:261) [na:na]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:261) [na:na]
at scala.Option.map(Option.scala:145) [na:na]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$2.applyOrElse(PlayDefaultUpstreamHandler.scala:261) [na:na]
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_05]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_05]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_05]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_05]
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:191) ~[na:na]
at play.utils.crud.TemplateController.call(TemplateController.java:97) ~[na:na]
As you can see
[debug] p.u.c.CRUDController - model : Voeding [key=1, name=qsddqs]
is now reporting the correct model
Can you please fork the project and add your problem sample as a separate sample project under samples folder so I can have a closer look.
When trying to create your own SimpleForm, when using the edit function you will get an [IllegalArgumentException: argument type mismatch] error. The new object function works.
The error-log