dispatchComponentEvent is one of the methods of the Component [0] interface. Every page / component / mixin implements this interface through some class transformation by Tapestry. Same as with setupRender; if you don’t implement this method, Tapestry will do it for you.
[0] https://github.com/apache/tapestry5/blob/a197470fc1e698ca713741150114543a3f30d25b/tapestry-core/src/main/java/org/apache/tapestry5/runtime/Component.java > Am 23.03.2017 um 09:30 schrieb Davide Vecchi <d...@amc.dk>: > > Thank you. The problem was actually in the terms you mentioned. The null > value that was attempted to be passed in the primitive long argument was > coming from our customization of GridRows, which in its afterRender calls > ComponentResourcesCommon.createEventLink(String, Object...) for the > selectReceipt event. In some cases null is passed in the 2nd argument of the > createEventLink call, and that argument represents the context that will be > passed to the handler of created event. So when that event is triggered by > clicking a row, the onSelectReceipt handler is called and that null context > is attempted to be passed in the long argument, causing the null pointer. > > I'm still not clear if the first line of the stacktrace is normal, mentioning > a Receipts.dispatchComponentEvent method that doesn't exist and not > mentioning the line number, but anyway the null pointer was caused by the > null value that our code was erroneously setting as the event context. > > Thanks a lot for your help. > > -----Original Message----- > From: Christian Riedel [mailto:cr.ml...@googlemail.com] > Sent: Wednesday, March 22, 2017 19:32 > To: Tapestry users <users@tapestry.apache.org> > Subject: Re: NPE in dispatchComponentEvent of a page class (which doesn't > have such method) > > Just a wild guess without seeing your template: your method is called with a > null value. Assigning null to a primitive variable results in a nullpointer. > Try *Long* sysRowId instead and you probably won’t get that exception. The > root cause might be that the context of your event link does not contain the > value that it should. > Check the network inspector in your browser to see what’s sent to the server. > > > Christian > > >> Am 22.03.2017 um 15:41 schrieb Davide Vecchi <d...@amc.dk>: >> >> Hi everybody, >> >> I'm using Tapestry 5.3.8 . I am at a complete loss trying to figure out why >> I always get a NullPointerException when I click on a grid row of a certain >> page. >> >> I'm describing the situation here and if anyone has *any* thought, feeling, >> suggestion, observation, things to check or anything else about one or more >> parts of this issue, I would really appreciate to hear about it, because I >> know it's impossible to think of a solution for this kind of problem, and >> anything that *potentially* could allow me to get a tiny bit closer to the >> solution or narrow down the possible cause or discard possibilities is very >> welcome. I'm at the stage where I'm progressively removing stuff from that >> page until the crash disappears so I will know that was the "cause"... >> >> The weird thing is that in the Java side I have a handler for the >> t:rowevent="selectReceipt" event, and if such method is coded without >> any argument, like >> >> public void onSelectReceipt () // This works normally. >> { >> System.out.println("onSelectReceipt () executed"); >> } >> >> , then when I click on a grid row this null pointer doesn't occur and the >> method is entered, but if I add an argument to it which is the row index >> (like all the other grids of this webapp have), then the null pointer on >> click does occur and the method is not entered: >> >> public void onSelectReceipt (long sysRowId) // This causes the NPE. >> { >> System.out.println("onSelectReceipt (" + sysRowId + ") >> executed"); >> } >> >> To make this even more interesting... if both the above mentioned handlers >> are there, the null pointer occurs. Then I just remove the 1-argument >> handler and the null pointer doesn't occur. So, the mere presence of the >> non-working, 1-argument handler causes the null pointer, even if the >> working, no-arguments handler is there as well. >> >> We use a customized grid, but the grid in the problematic page is being used >> in the same way as the grids in all the other pages, which all have the >> 1-argument handler and don't have this problem. >> >> If the cause was that (for some reason unknown to me) the 1-argument handler >> was not recognized as the handler of the t:rowevent="selectReceipt" event, I >> would expect that the exception would be a TapestryException "... you must >> provide a matching event handler method ...", as it always happens when I >> forget to write the event handler. Instead I get this null pointer. And if >> in this page itself I omit the 1-argument event handler too, then I do get >> that TapestryException as expected; but when I put it back I get the null >> pointer, and the method is not even entered. >> >> This is the full stacktrace of the NullPointerException, from the exception >> page. The first line is the one that puzzles me the most, because >> Receipts.java is actually the problematic page, but it does not have the >> dispatchComponentEvent method, plus that line doesn't show the number of the >> line of source code or "Unknown Source", while all the others do. >> >> en.abc.link.tapestry.pages.function.magazines.receipts.Receipts.dispat >> chComponentEvent(Receipts.java) >> org.apache.tapestry5.internal.structure.ComponentPageElementImpl.dispa >> tchEvent(ComponentPageElementImpl.java:932) >> org.apache.tapestry5.internal.structure.ComponentPageElementImpl.proce >> ssEventTriggering(ComponentPageElementImpl.java:1117) >> org.apache.tapestry5.internal.structure.ComponentPageElementImpl.acces >> s$3100(ComponentPageElementImpl.java:61) >> org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.inv >> oke(ComponentPageElementImpl.java:1062) >> org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.inv >> oke(ComponentPageElementImpl.java:1060) >> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(Operatio >> nTrackerImpl.java:74) >> org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(Per >> ThreadOperationTracker.java:87) >> org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.jav >> a:1124) >> org.apache.tapestry5.internal.structure.ComponentPageElementResourcesI >> mpl.invoke(ComponentPageElementResourcesImpl.java:146) >> org.apache.tapestry5.internal.structure.ComponentPageElementImpl.trigg >> erContextEvent(ComponentPageElementImpl.java:1058) >> org.apache.tapestry5.internal.services.AjaxComponentEventRequestHandle >> r.handle(AjaxComponentEventRequestHandler.java:110) >> org.apache.tapestry5.internal.services.ajax.AjaxFormUpdateFilter.handl >> e(AjaxFormUpdateFilter.java:56) >> $ComponentEventRequestHandler_18b9bf935047d.handle(Unknown Source) >> $ComponentEventRequestHandler_18b9bf935028e.handle(Unknown Source) >> org.apache.tapestry5.internal.services.AjaxFilter.handle(AjaxFilter.ja >> va:42) $ComponentEventRequestHandler_18b9bf9350290.handle(Unknown >> Source) >> org.apache.tapestry5.upload.internal.services.UploadExceptionFilter.ha >> ndle(UploadExceptionFilter.java:75) >> $ComponentEventRequestHandler_18b9bf9350290.handle(Unknown Source) >> org.apache.tapestry5.services.TapestryModule$41.handle(TapestryModule. >> java:2475) $ComponentEventRequestHandler_18b9bf9350290.handle(Unknown >> Source) $ComponentEventRequestHandler_18b9bf9350123.handle(Unknown >> Source) >> org.apache.tapestry5.internal.services.ComponentRequestHandlerTerminat >> or.handleComponentEvent(ComponentRequestHandlerTerminator.java:43) >> en.abc.zcore.tapestry.services.XKernelThreadFilter.handleComponentEven >> t(XKernelThreadFilter.java:27) >> $ComponentRequestFilter_18b9bf9350121.handleComponentEvent(Unknown >> Source) >> $ComponentRequestHandler_18b9bf9350125.handleComponentEvent(Unknown >> Source) >> en.abc.zcore.tapestry.services.MDCFilter.handleComponentEvent(MDCFilte >> r.java:33) >> $ComponentRequestFilter_18b9bf9350120.handleComponentEvent(Unknown >> Source) >> $ComponentRequestHandler_18b9bf9350125.handleComponentEvent(Unknown >> Source) >> en.abc.zcore.tapestry.services.filters.ABCDatabaseSessionFilter.handle >> ComponentEvent(ABCDatabaseSessionFilter.java:104) >> $ComponentRequestFilter_18b9bf935011f.handleComponentEvent(Unknown >> Source) >> $ComponentRequestHandler_18b9bf9350125.handleComponentEvent(Unknown >> Source) >> org.apache.tapestry5.services.InitializeActivePageName.handleComponent >> Event(InitializeActivePageName.java:39) >> $ComponentRequestHandler_18b9bf9350125.handleComponentEvent(Unknown >> Source) >> org.tynamo.security.SecurityComponentRequestFilter.handleComponentEven >> t(SecurityComponentRequestFilter.java:41) >> $ComponentRequestFilter_18b9bf9350122.handleComponentEvent(Unknown >> Source) >> $ComponentRequestHandler_18b9bf9350125.handleComponentEvent(Unknown >> Source) >> $ComponentRequestHandler_18b9bf93500e0.handleComponentEvent(Unknown >> Source) >> org.apache.tapestry5.internal.services.ComponentEventDispatcher.dispat >> ch(ComponentEventDispatcher.java:46) >> $Dispatcher_18b9bf93500e4.dispatch(Unknown Source) >> $Dispatcher_18b9bf93500dc.dispatch(Unknown Source) >> org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator. >> service(TapestryModule.java:302) >> en.abc.link.tapestry.services.DoerModule$2.service(DoerModule.java:955 >> ) $RequestFilter_18b9bf93500db.service(Unknown Source) >> $RequestHandler_18b9bf93500dd.service(Unknown Source) >> org.apache.tapestry5.internal.services.RequestErrorFilter.service(Requ >> estErrorFilter.java:26) $RequestHandler_18b9bf93500dd.service(Unknown >> Source) >> org.apache.tapestry5.services.TapestryModule$3.service(TapestryModule. >> java:902) $RequestHandler_18b9bf93500dd.service(Unknown Source) >> org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule. >> java:892) $RequestHandler_18b9bf93500dd.service(Unknown Source) >> org.apache.tapestry5.internal.services.StaticFilesFilter.service(Stati >> cFilesFilter.java:90) $RequestHandler_18b9bf93500dd.service(Unknown >> Source) >> org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke( >> CheckForUpdatesFilter.java:105) >> org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke( >> CheckForUpdatesFilter.java:96) >> org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(Conc >> urrentBarrier.java:85) >> org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(C >> heckForUpdatesFilter.java:119) >> $RequestHandler_18b9bf93500dd.service(Unknown Source) >> $RequestHandler_18b9bf93500b6.service(Unknown Source) >> org.apache.tapestry5.services.TapestryModule$HttpServletRequestHandler >> Terminator.service(TapestryModule.java:253) >> org.tynamo.security.services.impl.SecurityConfiguration$1.call(Securit >> yConfiguration.java:59) >> org.tynamo.security.services.impl.SecurityConfiguration$1.call(Securit >> yConfiguration.java:54) >> org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallabl >> e.java:90) >> org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable. >> java:83) >> org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingS >> ubject.java:383) >> org.tynamo.security.services.impl.SecurityConfiguration.service(Securi >> tyConfiguration.java:54) >> $HttpServletRequestFilter_18b9bf93500b5.service(Unknown Source) >> $HttpServletRequestHandler_18b9bf93500b8.service(Unknown Source) >> org.apache.tapestry5.upload.internal.services.MultipartServletRequestF >> ilter.service(MultipartServletRequestFilter.java:44) >> $HttpServletRequestHandler_18b9bf93500b8.service(Unknown Source) >> org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java: >> 53) $HttpServletRequestHandler_18b9bf93500b8.service(Unknown Source) >> org.got5.tapestry5.jquery.services.AjaxUploadServletRequestFilter.serv >> ice(AjaxUploadServletRequestFilter.java:27) >> $HttpServletRequestHandler_18b9bf93500b8.service(Unknown Source) >> org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(Igno >> redPathsFilter.java:62) >> $HttpServletRequestFilter_18b9bf93500b2.service(Unknown Source) >> $HttpServletRequestHandler_18b9bf93500b8.service(Unknown Source) >> org.apache.tapestry5.services.TapestryModule$1.service(TapestryModule. >> java:852) $HttpServletRequestHandler_18b9bf93500b8.service(Unknown >> Source) $HttpServletRequestHandler_18b9bf935009e.service(Unknown >> Source) >> org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:171) >> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletH >> andler.java:1751) >> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java: >> 582) >> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.ja >> va:143) >> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java >> :548) >> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandle >> r.java:226) >> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandle >> r.java:1180) >> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:5 >> 12) >> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler >> .java:185) >> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler >> .java:1112) >> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.ja >> va:141) >> org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(Conte >> xtHandlerCollection.java:213) >> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper. >> java:134) >> org.eclipse.jetty.server.Server.handle(Server.java:534) >> org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320) >> org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java >> :251) >> org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(Abstrac >> tConnection.java:283) >> org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110) >> org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint >> .java:93) >> org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executePr >> oduceConsume(ExecuteProduceConsume.java:303) >> org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceCo >> nsume(ExecuteProduceConsume.java:148) >> org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(Execu >> teProduceConsume.java:136) >> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool >> .java:671) >> org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool. >> java:589) >> java.lang.Thread.run(Thread.java:745) >> >> --------------------------------------------------------------------- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org