我无法在Wicket应用程序中确定RuntimeException的原因。我设置了很多断点,但是当我提交表单时,只有在表单加载时才会触发。这是堆栈:
WicketMessage:没有为类定义get方法:class this.is.my.class.WicketDocumentModel expression:DocumentUpload
根本原因:
org.apache.wicket.WicketRuntimeException:没有为类定义get方法:class this.is.my.class.WicketDocumentModel expression:DocumentUpload 在org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:445) at org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:287) 在org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:90) at org.apache.wicket.model.AbstractPropertyModel.getObject(AbstractPropertyModel.java:117) 在org.apache.wicket.Component.getDefaultModelObject(Component.java:1664) 在org.apache.wicket.Component $ 3.compare(Component.java:548) at org.apache.wicket.Component.setDefaultModelObject(Component.java:3049) 在org.apache.wicket.markup.html.form.FormComponent.updateModel(FormComponent.java:1168) 在org.apache.wicket.markup.html.form.upload.FileUploadField.updateModel(FileUploadField.java:100) 在org.apache.wicket.markup.html.form.Form $ FormModelUpdateVisitor.component(Form.java:225) at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:514) 在org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:493) 在org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrder(FormComponent.java:465) 在org.apache.wicket.markup.html.form.Form.internalUpdateFormComponentModels(Form.java:2051) 在org.apache.wicket.markup.html.form.Form.updateFormComponentModels(Form.java:2019) 在org.apache.wicket.markup.html.form.Form.process(Form.java:984) 在org.apache.wicket.markup.html.form.Form.process(Form.java:911) 在org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:876) 在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) 在org.apache.wicket.RequestCycle.step(RequestCycle.java:1329) 在org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428) 在org.apache.wicket.RequestCycle.request(RequestCycle.java:545) 在org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:456) 在org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:289) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263) 在org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190) 在org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283) 在org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767) 在org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697) 在org.apache.jk.common.ChannelSocket $ SocketConnection.runIt(ChannelSocket.java:889) at org.apache.tomcat.util.threads.ThreadPool $ ControlRunnable.run(ThreadPool.java:690) 在java.lang.Thread.run(Thread.java:619)
我确实找到了关于类似问题here的讨论,但是我还没有完全把那里提出的建议转化为我的情况的解决方案。我的类不包含名为DocumentUpload的Java变量,但确实包含:
fuf = new FileUploadField("DocumentUpload");
答案 0 :(得分:6)
我在这个问题上花了几个小时,而且在我发布SO之后20分钟,我想到了这个问题。修复方法是将上传字段声明转换为提供模型的声明,如下所示:
fuf = new FileUploadField("DocumentUpload", new Model<FileUpload>());
编辑:事实证明这与1.3 - &gt;有关。 1.4迁移。根据{{3}},
FileUploadField - 现在需要型号
FileUploadField现在需要一个模型。这意味着如果您以前使用过仅ID的&gt;构造函数(即新的FileUploadField(“myFileField”)),则需要将其更改为包含&gt;模型(即新的FileUploadField(“myFileField”,新模型()) ))。