B4J Question BANano WebSocket Server and WebApp: Errors

Mashiane

Expert
Licensed User
Longtime User
Hi

I have created a project based on this template.

1682600652048.png


I updated the BANanoServer.b4xlib as per solution provided here:


My app first attempt is running somewhat.

svdemo.jpg


I am attaching the logs here for more clarity on the issues.

Please help advise.

Thanks in advance for your cooperation.
 
Object should first be initialized (HttpSession).

Code: Copy
Connected
java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (HttpSession).
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:140)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:204)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.RuntimeException: Object should first be initialized (HttpSession).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:49)
    at anywheresoftware.b4j.object.HttpSessionWrapper.SetAttribute(HttpSessionWrapper.java:78)
    at com.ab.banano.BANano.UpdateFromCacheDebug(Unknown Source)
    at com.ab.banano.BANano.B4JUpdateFromCache(Unknown Source)
    at b4j.example.bananoserver._updatefromcache(bananoserver.java:1582)
    at b4j.example.serverindex._websocket_connected(serverindex.java:102)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    ... 7 more

SOLUTION

On the SERVER??? class, on sub, WebSocket_Connected

I have added a try catch clause

Code: Copy
Try
        ' Lets update the cache with this class
        CacheReport = Main.Server.UpdateFromCache(Me, ws)
        'Log("PageID: " & CacheReport.BANPageID)
        'Log("Comes From Cache:" & CacheReport.ComesFromCache)
        'Log("Is a reconnecting socket: " & CacheReport.IsReconnected)
    Catch
    End Try    'ignore
 
Upvote 0
Back
Top