Lucee 6 RC and issue with websockets extension

Trying out Lucee 6. Installed websocket extension and followed instructions at GitHub - isapir/lucee-websocket: Enables server WebSockets for Lucee via JSR-356 compliant servlet containers (e.g. Tomcat 8, Jetty 9.1, etc.) for web.xml settings. Get the following error message:

Unable to resolve net.twentyonesolutions.luceewebsocket [68](R 68.0): missing requirement [net.twentyonesolutions.luceewebsocket [68](R 68.0)] osgi.wiring.package; (osgi.wiring.package=net.twentyonesolutions.lucee.app) Unresolved requirements: [[net.twentyonesolutions.luceewebsocket [68](R 68.0)] osgi.wiring.package; (osgi.wiring.package=net.twentyonesolutions.lucee.app)]

Stack trace as below. Tried 6.0-SNAPSHOT with same error message. Tried downgrading Lucee through 5.x series, and the last version in which the extension works (i.e., no error message) is Lucee 5.3.10.120.

Any thoughts on how to fix? Or should I file a bug report?

Don’t forget to tell us about your stack!

OS: Mac OS X (10.16) 64bit
Java Version: 15.0.2 (Oracle Corporation) 64bit
Tomcat Version: 9.0.11
Lucee Version: 6.0.0.503-RC

  at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4398)
  at org.apache.felix.framework.Felix.startBundle(Felix.java:2308)
  at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:1006)
  at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:992)
  at lucee.loader.osgi.BundleUtil.start(BundleUtil.java:112)
  at lucee.loader.osgi.BundleUtil.start(BundleUtil.java:108)
  at lucee.runtime.osgi.OSGiUtil._start(OSGiUtil.java:1377)
  at lucee.runtime.osgi.OSGiUtil._startIfNecessary(OSGiUtil.java:1330)
  at lucee.runtime.osgi.OSGiUtil.startIfNecessary(OSGiUtil.java:1325)
  at lucee.runtime.osgi.OSGiUtil._loadBundle(OSGiUtil.java:693)
  at lucee.runtime.osgi.OSGiUtil._loadBundle(OSGiUtil.java:636)
  at lucee.runtime.osgi.OSGiUtil.loadBundle(OSGiUtil.java:626)
  at lucee.runtime.osgi.OSGiUtil.loadBundle(OSGiUtil.java:615)
  at lucee.runtime.osgi.OSGiUtil$BundleDefinition.getBundle(OSGiUtil.java:1949)
  at lucee.commons.lang.ClassUtil.loadClassByBundle(ClassUtil.java:179)
  at lucee.commons.lang.ClassUtil.loadClassByBundle(ClassUtil.java:154)
  at lucee.runtime.functions.FunctionHandlerPool.use(FunctionHandlerPool.java:59)
  at lucee.runtime.functions.FunctionHandlerPool.invoke(FunctionHandlerPool.java:40)
  at mixins.websocketsmanager_cfc$cf.initComponent(/app/server/mixins/WebSocketsManager.cfc:4)
  at mixins.websocketsmanager_cfc$cf.newInstance(/app/server/mixins/WebSocketsManager.cfc:1)
  at lucee.runtime.component.ComponentLoader.initComponent(ComponentLoader.java:653)
  at lucee.runtime.component.ComponentLoader._loadComponent(ComponentLoader.java:592)
  at lucee.runtime.component.ComponentLoader.load(ComponentLoader.java:496)
  at lucee.runtime.component.ComponentLoader._search(ComponentLoader.java:298)
  at lucee.runtime.component.ComponentLoader._search(ComponentLoader.java:191)
  at lucee.runtime.component.ComponentLoader.searchComponent(ComponentLoader.java:84)
  at lucee.runtime.PageContextImpl.loadComponent(PageContextImpl.java:3295)
  at lucee.runtime.functions.other.CreateObject.doComponent(CreateObject.java:148)
  at lucee.runtime.functions.other._CreateComponent.call(_CreateComponent.java:42)
  at mixins.messagingmanager_cfc$cf.initComponent(/app/server/mixins/MessagingManager.cfc:7)
  at mixins.messagingmanager_cfc$cf.newInstance(/app/server/mixins/MessagingManager.cfc:1)
  at lucee.runtime.component.ComponentLoader.initComponent(ComponentLoader.java:653)
  at lucee.runtime.component.ComponentLoader._loadComponent(ComponentLoader.java:592)
  at lucee.runtime.component.ComponentLoader.load(ComponentLoader.java:496)
  at lucee.runtime.component.ComponentLoader._search(ComponentLoader.java:298)
  at lucee.runtime.component.ComponentLoader._search(ComponentLoader.java:191)
  at lucee.runtime.component.ComponentLoader.searchComponent(ComponentLoader.java:84)
  at lucee.runtime.PageContextImpl.loadComponent(PageContextImpl.java:3295)
  at lucee.runtime.functions.other.CreateObject.doComponent(CreateObject.java:148)
  at lucee.runtime.functions.other._CreateComponent.call(_CreateComponent.java:42)
  at mixins.appinit_cfm$cf.udfCall(/app/server/mixins/appInit.cfm:59)
  at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
  at lucee.runtime.type.UDFImpl._call(UDFImpl.java:348)
  at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223)
  at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:787)
  at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787)
  at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1777)
  at mixins.appinit_cfm$cf.call(/app/server/mixins/appInit.cfm:4)
  at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1058)
  at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:950)
  at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:931)
  at application_cfc$cf.udfCall(/app/server/Application.cfc:16)
  at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
  at lucee.runtime.type.UDFImpl._call(UDFImpl.java:348)
  at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223)
  at lucee.runtime.ComponentImpl._call(ComponentImpl.java:699)
  at lucee.runtime.ComponentImpl._call(ComponentImpl.java:587)
  at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1962)
  at lucee.runtime.listener.ModernAppListener.call(ModernAppListener.java:446)
  at lucee.runtime.listener.ModernAppListener.onApplicationStart(ModernAppListener.java:308)
  at lucee.runtime.PageContextImpl.initApplicationContext(PageContextImpl.java:3179)
  at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:124)
  at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:44)
  at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2494)
  at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2480)
  at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2451)
  at lucee.runtime.engine.Request.exe(Request.java:45)
  at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1218)
  at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1164)
  at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97)
  at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
  at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
  at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
  at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
  at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:770)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
  at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  at java.base/java.lang.Thread.run(Thread.java:832)
 Caused by: org.osgi.framework.BundleException: Unable to resolve net.twentyonesolutions.luceewebsocket [68](R 68.0): missing requirement [net.twentyonesolutions.luceewebsocket [68](R 68.0)] osgi.wiring.package; (osgi.wiring.package=net.twentyonesolutions.lucee.app) Unresolved requirements: [[net.twentyonesolutions.luceewebsocket [68](R 68.0)] osgi.wiring.package; (osgi.wiring.package=net.twentyonesolutions.lucee.app)]
  ... 94 more

Would someone be able to comment on this @Zackster @isapir ? Would love to upgrade to newer version of Lucee 5.4.x and do some more testing on Lucee 6 but this is a huge roadblock.

And if Websockets aren’t working with 5.4 or 6.0:

  1. What is the official recommendation on how to use Websockets with Lucee?
  2. Shouldn’t the GitHub - isapir/lucee-websocket: Enables server WebSockets for Lucee via JSR-356 compliant servlet containers (e.g. Tomcat 8, Jetty 9.1, etc.) extension be removed from the application provider store for 5.4.x and 6.x?
  3. Shouldn’t the Lucee Documentation be updated to let people know not to pursue this path via GitHub - isapir/lucee-websocket: Enables server WebSockets for Lucee via JSR-356 compliant servlet containers (e.g. Tomcat 8, Jetty 9.1, etc.)?

Thanks!
Cage

Seeing this post I worried a bit and did some trial and error before updating.

The last working snapshot without changing much (only web.xml) was 5.4.0.63-SNAPSHOT (tested on express variant), after that I get the same error as you.
However I was able to get it to work with new versions as well (tried 5.4.3.2 and 6.0.0.519-RC), albeit not in a nice way (?).

Comparing the two tags (.63 - .65), one relevant commit comes up, which might have changed how certain files get loaded. I don’t quite understand it though.

Either way looking in the lucee-admin > Info - Bundle (jar) I saw that one of the .jar files didn’t get loaded.

After a few search queries I found this answer on StackOverflow and adapted it to the problem (looking at isapir/lucee-apps for possible classnames or by unzipping the local jar).

createObject('java', 'net.twentyonesolutions.lucee.app.LuceeApps', 'net.twentyonesolutions.luceeapps');

Adding this before the WebsocketServer call loads the .jar and makes it work, however I don’t know how long it will stay loaded.

Still trying to understand the OSGi package loading, maybe the extension just needs to be repacked, missing options in MANIFEST.MF or pom.xml? :man_shrugging: (as the last changes are already 6-7 years old)


detailed steps
  1. download 5.4.3.2 express
  2. unpack/startup/set password etc.
  3. install extension via server context
    make sure it’s version 2.0.3, it’s the newest even though it will tell you it’s not
  4. stop lucee
  5. edit web.xml (with info found in your fork or in the issues in the original repository)
<!-- Required for the Lucee WebSocket Extension !-->
<filter>
  <filter-name>HttpSessionInitializerFilter</filter-name>
  <filter-class>org.apache.catalina.filters.SessionInitializerFilter</filter-class>
</filter>

<!-- modify url-pattern to match your websocket endpoints !-->
<filter-mapping>
  <filter-name>HttpSessionInitializerFilter</filter-name>
  <url-pattern>/ws/*</url-pattern>
</filter-mapping>
  1. start lucee
  2. copy chat example from Example Chat · isapir/lucee-websocket Wiki · GitHub to webroot
    keep in mind WebsocketRegister changed to WebsocketServer, so needs to be changed.
  3. change part of Application.cfc
createObject('java', 'net.twentyonesolutions.lucee.app.LuceeApps', 'net.twentyonesolutions.luceeapps');
WebsocketServer("/ws/chat/{channel}", new ChatListener());
  1. open chat page index.cfm?username=alice and check browser console.
    send message wschat.send('hi bob')
    in theory it should work, at least it does for me.

As far as I remember I saw that WebSockets might come with Lucee 6? At least it was in a slide from cfcamp - not sure if they had time to mention it though, as other cool features where presented.

3 Likes

Legend! That works yea, I will check how long it will stay connected. For now it looks like it stays connected, if it doesn’t work after some days I will just revert to an earlier version. Thanks for sharing your detailed steps ^^

1 Like

I finally reached the bottom of the internet and found your example and got up and going. I have wasted days trying to get websockets to work. Thank you. The documentation is not up to date. They talk about editing the xml and that only caused Tomcat to stop working for me. Then they talked about a jar file and there were absolutely no instructions on where to obtain the jar file and could find nothing on google search. It would be nice and considered necessary for Lucee to get websockets implementation up to date or implement the tag like CF does. Now I am looking at how to do this in a docker image and do all the reverse proxy to allow it to run on Unraid.

3 Likes