B4J Question B4j Server + PyBridge [Standalone Package]

ilan

Expert
Licensed User
Longtime User
Hi

i am trying to create a standalone package for my b4j server that also runs pybridge. if i run the server in debug AND release mode everything works fine but if i create a standalone package it create the exe file and everything that it needs but when i run the server it getting errors. i think something is missing and is not copied related to pybridge when creating the standalone package. i am also using resumable sub & pybridge with handlers correctly as described here:


this is the error msg i am getting:

B4X:
C:\Users\ilan-t\OneDrive - Ricor\Documents\b4x\CMM-Helper\CMM-Helper\CMM-Helper\cnc.local\b4j-server\cmm-helper\server>cd bin

C:\Users\ilan-t\OneDrive - Ricor\Documents\b4x\CMM-Helper\CMM-Helper\CMM-Helper\cnc.local\b4j-server\cmm-helper\server\bin>java.exe @release_java_modules.txt  -m b4j/www.sagital.cmmhelper.main
2026-09-06 12:17:14.269:INFO :oejs.Server:main: jetty-12.1.10; built: 2026-05-31T04:45:52.925Z; git: 986024525891c2c20ff08c58ba300dc3b9847586; jvm 19.0.2+7-44
2026-09-06 12:17:14.292:INFO :oejs.RequestLogWriter:main: Opened C:\Users\ilan-t\OneDrive - Ricor\Documents\b4x\CMM-Helper\CMM-Helper\CMM-Helper\cnc.local\b4j-server\cmm-helper\server\bin\logs\b4j-2026_09_06.request.log
2026-09-06 12:17:14.313:INFO :oejs.DefaultSessionIdManager:main: Session workerName=node0
2026-09-06 12:17:14.318:INFO :oejsh.ContextHandler:main: Started oeje11s.ServletContextHandler@1fa121e2{ROOT,/,b=file:///C:/Users/ilan-t/OneDrive%20-%20Ricor/Documents/b4x/CMM-Helper/CMM-Helper/CMM-Helper/cnc.local/b4j-server/cmm-helper/server/bin/www/,a=AVAILABLE,h=oeje11s.SessionHandler@7eac9008{STARTED}}
2026-09-06 12:17:14.320:INFO :oeje11s.ServletContextHandler:main: Started oeje11s.ServletContextHandler@1fa121e2{ROOT,/,b=file:///C:/Users/ilan-t/OneDrive%20-%20Ricor/Documents/b4x/CMM-Helper/CMM-Helper/CMM-Helper/cnc.local/b4j-server/cmm-helper/server/bin/www/,a=AVAILABLE,h=oeje11s.SessionHandler@7eac9008{STARTED}}
2026-09-06 12:17:14.395:INFO :oejs.AbstractConnector:main: Started oejs.ServerConnector@68567e20{HTTP/1.1, (http/1.1)}{0.0.0.0:8000}
2026-09-06 12:17:14.396:INFO :oejs.Server:main: Started oejs.Server@fa36558{STARTING}[12.1.10,sto=0] @129ms
(b4j) Server is listening on port: 64199
Python executable not found!
PyBridge disconnected!!!
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at b4j/anywheresoftware.b4j.object.JServlet.createInstance(Unknown Source)
        at b4j/anywheresoftware.b4j.object.BackgroundWorkersManager$1.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot invoke "www.sagital.cmmhelper.b4xorderedmap._containskey(Object)" because "this._map" is null
        at b4j/anywheresoftware.b4a.keywords.Common.CallSub4(Unknown Source)
        at b4j/anywheresoftware.b4a.keywords.Common.access$0(Unknown Source)
        at b4j/anywheresoftware.b4a.keywords.Common$CallSubDelayedHelper.run(Unknown Source)
        at b4j/anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(Unknown Source)
        at b4j/anywheresoftware.b4a.StandardBA.startMessageLoop(Unknown Source)
        at b4j/anywheresoftware.b4a.keywords.Common.StartMessageLoop(Unknown Source)
        at b4j/www.sagital.cmmhelper.pybridgeworker._initialize(Unknown Source)
        ... 5 more
Caused by: java.lang.RuntimeException: java.lang.NullPointerException: Cannot invoke "www.sagital.cmmhelper.b4xorderedmap._containskey(Object)" because "this._map" is null
        at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
        ... 12 more
Caused by: java.lang.NullPointerException: Cannot invoke "www.sagital.cmmhelper.b4xorderedmap._containskey(Object)" because "this._map" is null
        at b4j/www.sagital.cmmhelper.b4xset._contains(Unknown Source)
        at b4j/www.sagital.cmmhelper.pybridge._registermember(Unknown Source)
        at b4j/www.sagital.cmmhelper.pybridge._runcode(Unknown Source)
        at b4j/www.sagital.cmmhelper.pybridgeworker$ResumableSub_FetchStationItems.resume(Unknown Source)
        at b4j/www.sagital.cmmhelper.pybridgeworker._fetchstationitems(Unknown Source)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        ... 13 more

if i run in DEBUG OR RELEASE mode everything works fine only if i run the server from the standalone file that is created it is giving me this error.


python lib i am using:


from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time
 

ilan

Expert
Licensed User
Longtime User
sorry i put this thread in the wrong forum. please move to b4j questions!

so changing the path to python solved the issue. the thing is when i install the python libraries they are installed to the anywhere software python path:


B4X:
Private Sub Start
    py.Initialize(Me, "py")
'    Dim opt As PyOptions = py.CreateOptions("Python/python/python.exe")
    Dim opt As PyOptions = py.CreateOptions("C:/Program Files/Anywhere Software/B4J/Libraries/Python/python/python.exe")
    py.Start(opt)
    Wait For py_Connected (Success As Boolean)
    If Success = False Then
        py_Disconnected
        Return
    End If
End Sub

i assumed that when you create a standalone package this folder is also copied. now the problem is if it is not i need to manually copy whole this folder with the app if i want to run it on a different pc. is there another solution?
 
Upvote 0
Top