scaladin icon indicating copy to clipboard operation
scaladin copied to clipboard

NPE at com.vaadin.data.fieldgroup.FieldGroup.commit

Open thehappycoder opened this issue 10 years ago • 2 comments

When I click the submit button, I get

SEVERE: 
com.vaadin.server.ServerRpcManager$RpcInvocationException: Unable to invoke method click in com.vaadin.shared.ui.button.ButtonServerRpc
    at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:170)
    at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118)
    at com.vaadin.server.communication.ServerRpcHandler.handleBurst(ServerRpcHandler.java:207)
    at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:111)
    at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:91)
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:37)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1390)
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:711)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:552)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:568)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1112)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:479)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1046)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:199)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle(Server.java:462)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:281)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:232)
    at org.eclipse.jetty.io.AbstractConnection$1.run(AbstractConnection.java:505)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:168)
    ... 27 more
Caused by: com.vaadin.event.ListenerMethod$MethodException: Invocation of method buttonClick in vaadin.scala.internal.ButtonClickListener failed.
    at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:528)
    at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198)
    at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
    at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:969)
    at com.vaadin.ui.Button.fireClick(Button.java:368)
    at com.vaadin.ui.Button$1.click(Button.java:57)
    ... 32 more
Caused by: java.lang.NullPointerException
    at com.vaadin.data.fieldgroup.FieldGroup.commit(FieldGroup.java:442)
    at vaadin.scala.FieldGroup$$anonfun$commit$1.apply$mcV$sp(FieldGroup.scala:100)
    at vaadin.scala.FieldGroup$$anonfun$commit$1.apply(FieldGroup.scala:100)
    at vaadin.scala.FieldGroup$$anonfun$commit$1.apply(FieldGroup.scala:100)
    at scala.util.control.Exception$Catch$$anonfun$either$1.apply(Exception.scala:124)
    at scala.util.control.Exception$Catch$$anonfun$either$1.apply(Exception.scala:124)
    at scala.util.control.Exception$Catch.apply(Exception.scala:102)
    at scala.util.control.Exception$Catch.either(Exception.scala:124)
    at vaadin.scala.FieldGroup.commit(FieldGroup.scala:100)
    at co.cleancode.scaladin.FieldGroup.commit(FieldGroup.scala:33)
    at co.cleancode.menu.views.product.ProductManageWindow$Form$$anon$11$$anonfun$10.apply(ProductManageWindow.scala:189)
    at co.cleancode.menu.views.product.ProductManageWindow$Form$$anon$11$$anonfun$10.apply(ProductManageWindow.scala:188)
    at vaadin.scala.internal.ButtonClickListener.buttonClick(listeners.scala:84)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
    ... 37 more

Here is the code: https://gist.github.com/thehappycoder/b697586fd89ea6b0cff2

After trial and error I figured that categoryId may be the cause but I don't understand why. And I cannot debug because of this issue https://github.com/henrikerola/sbt-vaadin-plugin/issues/10

thehappycoder avatar Aug 03 '14 10:08 thehappycoder

That's due to vaadin.scala.FieldGroup's buildAndBindMemberFields ignoring the result of bind(f, propertyId): Failure(com.vaadin.data.fieldgroup.FieldGroup$BindException: A property with id categoryId was not found in the item)

thehappycoder avatar Sep 19 '14 09:09 thehappycoder

Seems that vaadin's version of buildAndBindMemberFields allows to skip the binding but scaladin version doesn't allow. My form has this categoryId field that isn't supposed to be saved to database.

thehappycoder avatar Sep 19 '14 10:09 thehappycoder