Bug 65342

Summary: IllegalArgumentException "endpointClass cannot be null" after upgrade to 9.0.46
Product: Tomcat 9 Reporter: Rossen Stoyanchev <rstoyanchev>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 9.0.46   
Target Milestone: -----   
Hardware: PC   
OS: Linux   

Description Rossen Stoyanchev 2021-05-29 09:41:45 UTC
On upgrade from 9.0.45 to 9.0.46, we see failures in WebSocket integration tests with the following stacktrace:

java.lang.IllegalArgumentException: endpointClass cannot be null
	at javax.websocket.server.ServerEndpointConfig$Builder.<init>(ServerEndpointConfig.java:314)
	at javax.websocket.server.ServerEndpointConfig$Builder.create(ServerEndpointConfig.java:287)
	at org.apache.tomcat.websocket.WsSession.<clinit>(WsSession.java:77)
	at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServerRecursive(WsWebSocketContainer.java:498)
	at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:185)
	at org.springframework.web.reactive.socket.client.StandardWebSocketClient.lambda$executeInternal$0(StandardWebSocketClient.java:111)

I'm hoping the stacktrace provides enough of a clue. It looks like on line 77 WsSession invokes ServerEndpointConfig.Builder#create with null values which is then rejected by the create method. If not, I'll try and extract an isolated sample.
Comment 1 Mark Thomas 2021-05-29 11:44:39 UTC
Thanks, I can see what is going on.

The CDI integration needs to know if it can "short-cut" the Endpoint creation process and use the InstanceManager to create the Endpoint instance (which allows non-zero-arg constructors to be used) or whether the Endpoint instance needs to be created via the standard WebSocket mechanism and then passed to the InstanceManager.

I used a hack to figure this out that depends on how Tomcat implemented the WebSocket API. It appears you are using a different API implementation that has stricter checking. I should be able to fix this in the next release. In the meantime, a workaround would be to use the WebSocket API JAR from Tomcat 9.
Comment 2 Rossen Stoyanchev 2021-05-29 20:28:19 UTC
FWIW the relevant dependencies are tomcat-websocket, tomcat-embed-core, tomcat-util, and javax.websocket:javax.websocket-api and it's the ServerEndpointConfig.Builder in javax.websocket:javax.websocket-api where the exception is raised.
Comment 3 Mark Thomas 2021-06-03 09:51:40 UTC
Fixed in:
- 10.0.x for 10.0.7 onwards
- 9.0.x for 9.0.47 onwards
- 8.5.x for 8.5.67 onwards