B4J Question Stand alone packager error on windows

cbal03

Active Member
Licensed User
Longtime User
I received a few b4j does not declare 'uses' errors. I resolved 1 of them with
#PackagerProperty: AdditionalModuleInfoString = uses org.glassfish.tyrus.spi.ServerContainerFactory;

I don't know how to correct the next error:
jakarta.websocket.server.ServerEndpointConfig$Configurator: module b4j does not declare `uses`

The application runs fine in debug and release modes.

The full message is below for anyone's helpful advice. Thanks!

B4X:
D:\MY Apps\Basic4Java\ctb_media_server102\Objects\temp\build\bin>java.exe @relea
se_java_modules.txt  -m b4j/ctb.mms.main
Starting HTTP instances
Aug 09, 2025 1:29:29 AM org.glassfish.grizzly.http.server.NetworkListener start
INFO: Started listener bound to [0.0.0.0:4000]
Aug 09, 2025 1:29:29 AM org.glassfish.grizzly.http.server.HttpServer start
INFO: [HttpServer] Started.
websocket_server._startserver (java line: -1)
java.util.ServiceConfigurationError: jakarta.websocket.server.ServerEndpointConf
ig$Configurator: module b4j does not declare `uses`
        at java.base/java.util.ServiceLoader.fail(Unknown Source)
        at java.base/java.util.ServiceLoader.checkCaller(Unknown Source)
        at java.base/java.util.ServiceLoader.<init>(Unknown Source)
        at java.base/java.util.ServiceLoader.load(Unknown Source)
        at b4j/jakarta.websocket.server.ServerEndpointConfig$Configurator.fetchC
ontainerDefaultConfigurator(Unknown Source)
        at b4j/jakarta.websocket.server.DefaultServerEndpointConfig.<init>(Unkno
wn Source)
        at b4j/jakarta.websocket.server.ServerEndpointConfig$Builder.build(Unkno
wn Source)
        at b4j/org.glassfish.tyrus.core.AnnotatedEndpoint.createEndpointConfig(U
nknown Source)
        at b4j/org.glassfish.tyrus.core.AnnotatedEndpoint.<init>(Unknown Source)

        at b4j/org.glassfish.tyrus.core.AnnotatedEndpoint.fromClass(Unknown Sour
ce)
        at b4j/org.glassfish.tyrus.core.TyrusWebSocketEngine.register(Unknown So
urce)
        at b4j/org.glassfish.tyrus.container.grizzly.server.GrizzlyServerContain
er$TyrusGrizzlyServerContainer.register(Unknown Source)
        at b4j/org.glassfish.tyrus.server.TyrusServerContainer.start(Unknown Sou
rce)
        at b4j/org.glassfish.tyrus.container.grizzly.server.GrizzlyServerContain
er$TyrusGrizzlyServerContainer.start(Unknown Source)
        at b4j/org.glassfish.tyrus.server.Server.start(Unknown Source)
        at b4j/addo.jakarta.wserver.JakartaWsLibrary.Start(Unknown Source)
        at b4j/ctb.mms.websocket_server._startserver(Unknown Source)
        at b4j/ctb.mms.main._cb_serveron_checkedchange(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Nativ
e Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknow
n Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Un
known Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
        at b4j/anywheresoftware.b4a.BA$1.run(Unknown Source)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLat
er$10(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Unknown Source)

        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLat
er$11(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unk
nown Source)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native M
ethod)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(
Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)


D:\MY Apps\Basic4Java\ctb_media_server102\Objects\temp\build\bin>pause
Press any key to continue . . .
 

cbal03

Active Member
Licensed User
Longtime User
I added this
B4X:
#PackagerProperty: AdditionalModuleInfoString = uses jakarta.websocket.server.ServerEndpointConfig.Configurator;
and now the application starts from the run_debug.bat file but when I start the websocket via checkbox I get the error below.
If I comment out websocketserver . startServer then I get no errors. I'm not sure what else the packager needs for this to run correctly.
The application runs fine from the ide so I'm thinking the packager is missing something it needs to assemble the standalone exe properly.

I'm using the JakartaWsLibrary for this socket.

B4X:
java.lang.RuntimeException: Cannot load platform configurator
        at b4j/jakarta.websocket.server.ServerEndpointConfig$Configurator.fetchC
ontainerDefaultConfigurator(Unknown Source)
        at b4j/jakarta.websocket.server.DefaultServerEndpointConfig.<init>(Unkno
wn Source)
        at b4j/jakarta.websocket.server.ServerEndpointConfig$Builder.build(Unkno
wn Source)
        at b4j/org.glassfish.tyrus.core.AnnotatedEndpoint.createEndpointConfig(U
nknown Source)
        at b4j/org.glassfish.tyrus.core.AnnotatedEndpoint.<init>(Unknown Source)

        at b4j/org.glassfish.tyrus.core.AnnotatedEndpoint.fromClass(Unknown Sour
ce)
        at b4j/org.glassfish.tyrus.core.TyrusWebSocketEngine.register(Unknown So
urce)
        at b4j/org.glassfish.tyrus.container.grizzly.server.GrizzlyServerContain
er$TyrusGrizzlyServerContainer.register(Unknown Source)
        at b4j/org.glassfish.tyrus.server.TyrusServerContainer.start(Unknown Sou
rce)
        at b4j/org.glassfish.tyrus.container.grizzly.server.GrizzlyServerContain
er$TyrusGrizzlyServerContainer.start(Unknown Source)
        at b4j/org.glassfish.tyrus.server.Server.start(Unknown Source)
        at b4j/addo.jakarta.wserver.JakartaWsLibrary.Start(Unknown Source)
        at b4j/ctb.mms.websocket_server._startserver(Unknown Source)
        at b4j/ctb.mms.main._cb_serveron_checkedchange(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Nativ
e Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknow
n Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Un
known Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
        at b4j/anywheresoftware.b4a.BA$1.run(Unknown Source)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLat
er$10(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Unknown Source)

        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLat
er$11(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unk
nown Source)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native M
ethod)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(
Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)
 
Upvote 0

cbal03

Active Member
Licensed User
Longtime User
Good morning Erel,
I'm using jServer for http connections serving content. I'm using JakartaWsLibrary for the communications.. connect, auth, get media records, server info etc.. I like Jakarta for this because of the events it supports (_onOpen, onMessage, onClose, _on Error and _onException).

jServer is working fine as media is sent to the device but the jakarta websocket generates the error upon calling the start method after packaging. I found that the error java.lang.RuntimeException: Cannot load platform configurator may be due to a service injection issue. I found some info on the subject here https://github.com/jakartaee/websocket/issues/469

That post makes a suggestion on how to fix the issue however I can only look into the libraries. I cannot make changes to them.

The jakarta packages jServer uses from directory b4j\libraries\jserver package websocket-jakarta-server-11.0.9 (found in META-INF\maven\org.eclipse.jetty.websocket\websocket-jakarta-server\pom.xml) shows:

B4X:
              <instructions>
                <Bundle-Description>jakarta.websocket.server Implementation</Bundle-Description>
                <Export-Package>
                  org.eclipse.jetty.websocket.jakarta.server.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"
                </Export-Package>
                <Require-Capability>osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)";resolution:=optional</Require-Capability>
                <Provide-Capability>
                  osgi.serviceloader;osgi.serviceloader=org.eclipse.jetty.webapp.Configuration,osgi.serviceloader;osgi.serviceloader=jakarta.servlet.ServletContainerInitializer,osgi.serviceloader;osgi.serviceloader=jakarta.websocket.server.ServerEndpointConfig$Configurator
                </Provide-Capability>
              </instructions>

Which is probably why jServer works. The JakartaWsLibrary doesn't have this pom file. It just has a few classes.

I'm still trying to grasp the fundamental usage of options --add-exports, --add-opens, --add-modules, --add-reads, and --patch-module.
And am hoping that correctly implementing these will correct the issue.
Or maybe I'm way off base. :)
 
Upvote 0

cbal03

Active Member
Licensed User
Longtime User
I was able to get the jar to run by using this at the commandline. So possibly there are modules missing from the packaged to exe ??
"C:\Java\jdk-19.0.2\bin\java.exe" --module-path "C:\Java\jdk-19.0.2\javafx\lib" --add-modules ALL-MODULE-PATH -jar "D:\MY Apps\Basic4Java\ctb_media_server102\Objects\ctb_media_server.jar"

How do I find the missing modules and add them to the package?
 
Upvote 0
Top