Grid with Custom Components based on PolymerTemplate throw NPE
See original GitHub issueVaadin 14.1.1
I create own class component that extends PolymerTemplate.
Then i construct simple View extends VerticalLayout:
- create Grid component;
- add some columns to the Grid component, one of them is ComponentRenderer that realize my class;
- attach Grid component to the View invoking add() method; Then i take NPE on view access from browser.
java.lang.RuntimeException: Push failed
at com.vaadin.flow.server.communication.AtmospherePushConnection.push(AtmospherePushConnection.java:198)
at com.vaadin.flow.server.communication.AtmospherePushConnection.connect(AtmospherePushConnection.java:287)
at com.vaadin.flow.server.communication.PushHandler.lambda$new$0(PushHandler.java:97)
at com.vaadin.flow.server.communication.PushHandler.callWithUi(PushHandler.java:217)
at com.vaadin.flow.server.communication.PushHandler.onConnect(PushHandler.java:479)
at com.vaadin.flow.server.communication.PushAtmosphereHandler.onConnect(PushAtmosphereHandler.java:101)
at com.vaadin.flow.server.communication.PushAtmosphereHandler.onRequest(PushAtmosphereHandler.java:75)
at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:225)
at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:114)
at org.atmosphere.container.Servlet30CometSupport.service(Servlet30CometSupport.java:67)
at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:2297)
at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:594)
at org.atmosphere.websocket.DefaultWebSocketProcessor.open(DefaultWebSocketProcessor.java:224)
at org.atmosphere.container.JSR356Endpoint.onOpen(JSR356Endpoint.java:264)
at org.eclipse.jetty.websocket.jsr356.endpoints.JsrEndpointEventDriver.onConnect(JsrEndpointEventDriver.java:139)
at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.openSession(AbstractEventDriver.java:216)
at org.eclipse.jetty.websocket.jsr356.endpoints.AbstractJsrEventDriver.openSession(AbstractJsrEventDriver.java:103)
at org.eclipse.jetty.websocket.common.WebSocketSession.open(WebSocketSession.java:474)
at org.eclipse.jetty.websocket.common.WebSocketSession.onOpened(WebSocketSession.java:440)
at org.eclipse.jetty.io.AbstractConnection.onOpened(AbstractConnection.java:213)
at org.eclipse.jetty.io.AbstractConnection.onOpen(AbstractConnection.java:205)
at org.eclipse.jetty.io.AbstractEndPoint.upgrade(AbstractEndPoint.java:442)
at org.eclipse.jetty.server.HttpConnection.onCompleted(HttpConnection.java:385)
at org.eclipse.jetty.server.HttpChannel.onCompleted(HttpChannel.java:734)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:363)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:270)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:388)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException: null
at com.vaadin.flow.component.polymertemplate.PolymerTemplate.<init>(PolymerTemplate.java:103)
at ru.wap.wtwebordermanager.vaadincomponents.polymertextwithdblclick.PolymerTextWithDblClick.<init>(PolymerTextWithDblClick.java:25)
at ru.wap.wtwebordermanager.jettyserv.vaadin.ordermanager.rightpart.assignedordersgrid.AssignedOrdersGridColumns$1.apply(AssignedOrdersGridColumns.java:265)
at ru.wap.wtwebordermanager.jettyserv.vaadin.ordermanager.rightpart.assignedordersgrid.AssignedOrdersGridColumns$1.apply(AssignedOrdersGridColumns.java:254)
at com.vaadin.flow.data.renderer.ComponentRenderer.createComponent(ComponentRenderer.java:239)
at com.vaadin.flow.data.provider.ComponentDataGenerator.createComponent(ComponentDataGenerator.java:94)
at com.vaadin.flow.data.provider.ComponentDataGenerator.generateData(ComponentDataGenerator.java:83)
at com.vaadin.flow.data.provider.CompositeDataGenerator.lambda$generateData$0(CompositeDataGenerator.java:47)
at java.lang.Iterable.forEach(Iterable.java:75)
at com.vaadin.flow.data.provider.CompositeDataGenerator.generateData(CompositeDataGenerator.java:47)
at com.vaadin.flow.data.provider.DataCommunicator.generateJson(DataCommunicator.java:660)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.IntPipeline$4$1.accept(IntPipeline.java:250)
at java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:110)
at java.util.Spliterator$OfInt.forEachRemaining(Spliterator.java:693)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at com.vaadin.flow.data.provider.DataCommunicator.getJsonItems(DataCommunicator.java:617)
at com.vaadin.flow.data.provider.DataCommunicator.collectChangesToSend(DataCommunicator.java:560)
at com.vaadin.flow.data.provider.DataCommunicator.flush(DataCommunicator.java:477)
at com.vaadin.flow.data.provider.DataCommunicator.lambda$requestFlush$2f364bb9$1(DataCommunicator.java:425)
at com.vaadin.flow.internal.StateTree.lambda$runExecutionsBeforeClientResponse$1(StateTree.java:368)
at java.util.ArrayList.forEach(ArrayList.java:1257)
at com.vaadin.flow.internal.StateTree.runExecutionsBeforeClientResponse(StateTree.java:365)
at com.vaadin.flow.server.communication.UidlWriter.encodeChanges(UidlWriter.java:411)
at com.vaadin.flow.server.communication.UidlWriter.createUidl(UidlWriter.java:187)
at com.vaadin.flow.server.communication.UidlWriter.createUidl(UidlWriter.java:225)
at com.vaadin.flow.server.communication.AtmospherePushConnection.push(AtmospherePushConnection.java:194)
I look at default constructor of PolymerTemplate:
public PolymerTemplate() {
this(VaadinService.getCurrent().getDeploymentConfiguration()
.isCompatibilityMode() ? DefaultTemplateParser.getInstance()
: NpmTemplateParser.getInstance(),
VaadinService.getCurrent());
}
The VaadinService.getCurrent()
return NULL.
It looks like similar to #3789. From it i saw that i need to create components in current UI context. Is it true? If yes, why it is necessary? And why there is invocation of isCompatibilityMode()
? Is this redundant in the current version of Vaadin?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
NPE when I try to create a instance of a custom component ...
Hello, I'm using Vaadin 10.0.0.beta2 with Spring Boot 2. I have the following problem: When I try to create a new instance of...
Read more >Trying to create a custom polymer component using ag-grid
In your Polymer template's iron-ajax , bind the response to a property e.g., named rowData , and pass that to ag-grid via its...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As a workaround for this bug you may use protected constructor
PolymerTemplate(TemplateParser parser, VaadinService service)
and pass argument values explicitly by yourself.PushHandler::callWithUi
is invoked withwebsocket
parameter valuefalse
.As a resultif (websocket) {
is skipped and this part sets the Current instances. At the same time theAtmosphereResource
hastransport=WEBSOCKET
.So
websocket
parameter value is wrong. I have to find the reason why it’s wrong.