Websocket Extension not working with Lucee 7.x

Looks like the current version of the Websocket Extension ( 3.0.0.17 ) still has some dependencies on javax and I think because it was was made to be compatible with both javax and jakarta libraries, the wrapper isn’t being called.

I’m not seeing anything in /any/ of the logs to show that the extension is loading up, failing or anything else – other than the entries are showing in the .CFConfig file (under the startup hooks and in the extensions node), the .jar files are ending up in the right place, and I see the .lex in the context/extensions/installed directory.

When calling the websocketInfo() function, it does execute, but gives the “WebSocketEndpointFactory failed to initialize within the Lucee engine (startup-hook)” error.

Exact same setup works for Lucee 6.2.4.24-light.

OS: docker, image lucee/lucee:7.0.1.100-light, extension injected via ENV variable
Java Version: Eclipse Adoptium 21.0.9
Tomcat Version: Apache Tomcat/11.0.15
Lucee Version: 7.0.1.100-light

1 Like

I got same problem, is there any solution?

I have a fix in the works

https://luceeserver.atlassian.net/browse/LDEV-6050

in the meantime, the workaround should be to simply to drop these javax jars in your /lib folder

https://repo1.maven.org/maven2/javax/servlet/javax.servlet-api/4.0.1/javax.servlet-api-4.0.1.jar
https://repo1.maven.org/maven2/javax/servlet/jsp/javax.servlet.jsp-api/2.3.3/javax.servlet.jsp-api-2.3.3.jar
https://repo1.maven.org/maven2/javax/el/javax.el-api/3.0.0/javax.el-api-3.0.0.jar
https://repo1.maven.org/maven2/javax/websocket/javax.websocket-api/1.1/javax.websocket-api-1.1.jar

Try the 3.0.0.18-SNAPSHOT

https://download.lucee.org/#3F9DFF32-B555-449D-B0EB5DB723044045

1 Like

@Zackster – looks like 3.0.0.18-SNAPSHOT is doing the same thing.

Dropping the jar files you listed into /opt/lucee/server/lucee-server/context/lib/ and restarting the container didn’t seem to do much either. Same error about the startup hook when I run the websocketinfo() function call.

lucee.runtime.exp.ApplicationException: WebSocketEndpointFactory failed to initialize within the Lucee engine (startup-hook).
 at lucee.runtime.op.ExceptonImpl.createApplicationException(ExceptonImpl.java:93)
 at org.lucee.extension.websocket.WebSocketEndpointFactory.getInstance(WebSocketEndpointFactory.java:193)
 at org.lucee.extension.websocket.udf.WebsocketInfo.invoke(WebsocketInfo.java:42)
 at lucee.runtime.functions.FunctionHandlerPool.invoke(FunctionHandlerPool.java:40)
 at index_cfm$cf.call(/index.cfm:1)
.......

ahhh, try the 7.0.2.6-SNAPSHOT or newer

https://luceeserver.atlassian.net/browse/LDEV-5957

Getting closer. It looks like it’s choking on the websocket extension’s register() function now

Exception in thread "Thread-1" java.lang.NoSuchMethodError: 'javax.servlet.ServletContext lucee.runtime.config.ConfigWeb.getServletContext()'
2025-12-31T21:48:45.328236832Z 	at org.lucee.extension.websocket.WebSocketEndpointFactory.register(WebSocketEndpointFactory.java:85)
2025-12-31T21:48:45.328239089Z 	at org.lucee.extension.websocket.WebSocketEndpointFactory$Registrar.run(WebSocketEndpointFactory.java:265)

Not unexpected with the initial function call failing, when we call the websocketinfo() function, we get this:

31.12.2025 21:51:00,681 ERROR [server.websocket] 
2025-12-31T21:51:00.685645785Z lucee.runtime.exp.NativeException: lucee.runtime.thread.ThreadUtil.createPageContext(lucee.runtime.config.ConfigWeb,java.io.OutputStream,java.lang.String,java.lang.String,java.lang.String,[Ljavax.servlet.http.Cookie;,[Llucee.commons.lang.Pair;,[B,[Llucee.commons.lang.Pair;,lucee.runtime.type.Struct,boolean,long)
2025-12-31T21:51:00.685648086Z 	at java.lang.Class.getMethod(Unknown Source) ~[?:?]
2025-12-31T21:51:00.685649435Z 	at org.lucee.extension.websocket.util.WSUtil.createPageContext(WSUtil.java:356) ~[org.lucee.websocket.extension-3.0.0.18-SNAPSHOT.jar:?]
2025-12-31T21:51:00.685650453Z 	at org.lucee.extension.websocket.util.WSUtil.createPageContext(WSUtil.java:346) ~[org.lucee.websocket.extension-3.0.0.18-SNAPSHOT.jar:?]
2025-12-31T21:51:00.685651407Z 	at org.lucee.extension.websocket.WebSocketEndpointFactory.register(WebSocketEndpointFactory.java:103) ~[org.lucee.websocket.extension-3.0.0.18-SNAPSHOT.jar:?]
2025-12-31T21:51:00.685652320Z 	at org.lucee.extension.websocket.WebSocketEndpointFactory.getInfo(WebSocketEndpointFactory.java:187) ~[org.lucee.websocket.extension-3.0.0.18-SNAPSHOT.jar:?]
2025-12-31T21:51:00.685653246Z 	at org.lucee.extension.websocket.udf.WebsocketInfo.invoke(WebsocketInfo.java:42) ~[org.lucee.websocket.extension-3.0.0.18-SNAPSHOT.jar:?]
2025-12-31T21:51:00.685654178Z 	at lucee.runtime.functions.FunctionHandlerPool.invoke(FunctionHandlerPool.java:40) ~[7.0.2.35-SNAPSHOT.lco:?]
2025-12-31T21:51:00.685655071Z 	at index_cfm$cf.call(/index.cfm:1) ~[?:?]

Same error on the published 3.0.0.17.

Did you ever get anywhere with this?

Got exactly the same “getServletContext()” error

64 bit Linux

Tried Lucee 6 with stable extension releases, up to;

Lucee 7.0.2.76-SNAPSHOT
Tomcat 11.0.15
Java 21.0.9 (Eclipse Adoptium) 64bit
WS extension 3.0.0.18-SNAPSHOT

Should be all now working, fixes included adding full test coverage against Lucee 6.2 and 7.0

Websocket 3.0.0.19-SNAPSHOT

https://luceeserver.atlassian.net/browse/LDEV-6050

Websocket Client 2.3.0.8-SNAPSHOT

https://luceeserver.atlassian.net/browse/LDEV-6100

Sorry for the delay, please support our work on Lucee

So…

websocketInfo() is now ‘working’ - see dump below.

Problem now is that putting your example test.cfc file (from https://docs.lucee.org/recipes/websocket-extension.html) in the mapping directory shown in websocketInfo() (and restarting Lucee) doesn’t cause the ‘instances’ array to populate. The file and parent dir have chmod of 777 to rule out perms issues.

I can see this line (and only this line) in the logs ;

“websocket-endpoint-factory”,“checking for new web context to register, current interval [60000ms]”

image

i think that only currently gets populated once a websocket connection has been made, aka on demand

The instances array shows active WebSocket sessions , not available listener components.

I’ve updated the docs

Ah… ok. Thanks for this (and the fix!)

Ultimately my javascript client (from the recipe page) isn’t connecting successfully.

I’m running it via a local webpage connecting back to my remote server. My first ‘hmmm’ is to do with the port the WS stuff runs on. Is this configurable?

The recipe page says;

This extension adds a WebSocket Server to your Lucee Server that runs over TCP on port 80 for WS: and 443 for `WSS:

And indeed that page uses “ws://127.0.0.1:80/ws/test” for the websocket URL

Yet I see, variously, in the now working Lucee 7 Test

Connecting to: ws://localhost:8888/ws/TestListener

…and the screenshot for LDEV-5385 using port 9888

image

the port is the same as the other cfml code, so if tomcat is listening on 9888, then your webservices are on 9888

Tests pass on my side now! Thanks for checking into that Zack!

1 Like