views:

533

answers:

1

I'm having trouble pinning down the cause of a RuntimeException in a Wicket application. I've set numerous breakpoints, but none are firing when I submit my form, only when the form is loading. Here's the stack:

WicketMessage: No get method defined for class: class this.is.my.class.WicketDocumentModel expression: DocumentUpload

Root cause:

org.apache.wicket.WicketRuntimeException: No get method defined for class: class this.is.my.class.WicketDocumentModel expression: DocumentUpload at org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:445) at org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:287) at org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:90) at org.apache.wicket.model.AbstractPropertyModel.getObject(AbstractPropertyModel.java:117) at org.apache.wicket.Component.getDefaultModelObject(Component.java:1664) at org.apache.wicket.Component$3.compare(Component.java:548) at org.apache.wicket.Component.setDefaultModelObject(Component.java:3049) at org.apache.wicket.markup.html.form.FormComponent.updateModel(FormComponent.java:1168) at org.apache.wicket.markup.html.form.upload.FileUploadField.updateModel(FileUploadField.java:100) at org.apache.wicket.markup.html.form.Form$FormModelUpdateVisitor.component(Form.java:225) at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:514) at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:493) at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrder(FormComponent.java:465) at org.apache.wicket.markup.html.form.Form.internalUpdateFormComponentModels(Form.java:2051) at org.apache.wicket.markup.html.form.Form.updateFormComponentModels(Form.java:2019) at org.apache.wicket.markup.html.form.Form.process(Form.java:984) at org.apache.wicket.markup.html.form.Form.process(Form.java:911) at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:876) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:182) at org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73) at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92) at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250) at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329) at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428) at org.apache.wicket.RequestCycle.request(RequestCycle.java:545) at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:456) at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:289) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263) at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190) at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283) at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767) at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697) at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690) at java.lang.Thread.run(Thread.java:619)

I did find discussion about a similar issue here, but I haven't quite been able to turn the advice presented there into a solution for my situation. My class does not contain a Java variable named DocumentUpload, but does contain this:

fuf = new FileUploadField("DocumentUpload");
+3  A: 

I spent several hours on this issue, and once again, I figured it out 20 minutes after I posted to SO about it. The fix is to turn the upload field declaration into one that provides a model, like this:

fuf = new FileUploadField("DocumentUpload", new Model<FileUpload>());

EDIT: It turns out this was related to 1.3 -> 1.4 migration. Per the migration guide,

FileUploadField - now requires model

The FileUploadField now REQUIRES a model. This means that if you previously used the ID-only >constructor (i.e. new FileUploadField("myFileField")), you will need to change it to include >a model (i.e. new FileUploadField("myFileField", new Model())).

Lord Torgamus
Yup.. You were getting the "no get method defined" problem because it was assuming a ComponentPropertyModel (iirc) and was trying to read it's models from there, finding no get method for "DocumentUpload".. You can accept your own answer as an answer..
Tim