B4J Question java.lang.RuntimeException: Object should first be initialized (HttpSession).

birnesoft

Active Member
Licensed User
Longtime User
Hello,

Since version 9.80 my server don't work anymore. ( jdk-11.0.1 )
I've tested the sample (ServerExample) and it has the same problem.

java.lang.RuntimeException: Object should first be initialized (HttpSession).

Chat sample:
Sub Class_Globals
    Private ws As WebSocket
    Private txt, ChatTxt, Users, btnSend, btnLogout As JQueryElement
    Private name As String
End Sub

Public Sub Initialize
    
End Sub

Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
    ws = WebSocket1
    name = ws.Session.GetAttribute2("name", "")
    If name = "" Then
        'name not found. Go to the login page. This will happen if the user goes to the chat page directly.
        WebUtils.RedirectTo(ws, "index.html")
    Else
        'remove the attribute
        'the user will be redirected to the login page next time.
        ws.Session.SetAttribute("name", "")
        CallSubDelayed3(ChatShared, "NewConnection", Me, name)
        txt.RunMethod("select", Null)
    End If
End Sub

thanx Björn
 

hcm

Member
Licensed User
Longtime User
Hi Björn,
I get the same error message, but only when I access the WebApp through an iframe. Would be great to know if you have been able to solve the problem and how (if you still remember...)
Thanks,
Christoph
 
Upvote 0

birnesoft

Active Member
Licensed User
Longtime User
Hello,
its solved.
I've downloaded the new Chat Sample Code and made my code into the sample. Now it works. But I don't know why.
Björn
 
Upvote 0
Top