While testing component-runtime bump to 1.1.21 (tomcat 9.0.31) from 1.1.15 (tomcat 9.0.27) in Studio, I encountered the following exception:
[INFO] Deploying WebSocket(path=/websocket/v1/bus) ERROR: [org.apache.catalina.core.StandardContext.listenerStart] Exception sending context initialized event to listener instance of class [org.talend.sdk.component.server.configuration.WebSocketBroadcastSetup] java.lang.NullPointerException at org.talend.sdk.component.server.configuration.WebSocketBroadcastSetup.lambda$contextInitialized$7(WebSocketBroadcastSetup.java:200) at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) at java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:373) at java.util.ArrayList.forEach(ArrayList.java:1257) at java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:390) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:483) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) at org.talend.sdk.component.server.configuration.WebSocketBroadcastSetup.contextInitialized(WebSocketBroadcastSetup.java:198) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4685) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5146) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705) at org.apache.meecrowave.Meecrowave.deployWebapp(Meecrowave.java:420) at org.apache.meecrowave.Meecrowave.deployClasspath(Meecrowave.java:190) at org.talend.sdk.component.server.cli.EnhancedCli.run(EnhancedCli.java:52) at org.talend.sdk.component.studio.ProcessManager$2.run(ProcessManager.java:288) [SEVERE] Exception sending context initialized event to listener instance of class [org.talend.sdk.component.server.configuration.WebSocketBroadcastSetup] java.lang.NullPointerException at org.talend.sdk.component.server.configuration.WebSocketBroadcastSetup.lambda$contextInitialized$7(WebSocketBroadcastSetup.java:200) at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) at java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:373) at java.util.ArrayList.forEach(ArrayList.java:1257) at java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:390) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:483) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) at org.talend.sdk.component.server.configuration.WebSocketBroadcastSetup.contextInitialized(WebSocketBroadcastSetup.java:198) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4685) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5146) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705) at org.apache.meecrowave.Meecrowave.deployWebapp(Meecrowave.java:420) at org.apache.meecrowave.Meecrowave.deployClasspath(Meecrowave.java:190) at org.talend.sdk.component.server.cli.EnhancedCli.run(EnhancedCli.java:52) at org.talend.sdk.component.studio.ProcessManager$2.run(ProcessManager.java:288) ERROR: [org.apache.catalina.core.StandardContext.startInternal] One or more listeners failed to start. Full details will be found in the appropriate container log file [SEVERE] One or more listeners failed to start. Full details will be found in the appropriate container log file ERROR: [org.apache.catalina.core.StandardContext.startInternal] Context [] startup failed due to previous errors [SEVERE] Context [] startup failed due to previous errors
The fact is that the WebsocketContainer is not present in the ServletContext :
https://github.com/Talend/component-runtime/blob/8a9c504638fe31fb880f8795e8bcca4b6344d906/component-server-parent/component-server/src/main/java/org/talend/sdk/component/server/configuration/WebSocketBroadcastSetup.java#L116-L117i