B4J Question [ABMaterial] Web app with MsSQl database - b4a.BA Error

Bladimir Carrillo

Member
Licensed User
Longtime User
This error is related to web app posted here https://www.b4x.com/android/forum/threads/web-app-with-mssql-database.71243/#post-455994

Message related to b4a.BA appears some times after any page load
The error are showing from I has implemented a module to send messages to B4A android mobile app using websockets (appears at any time when I am not sending remote mesagges to device):


Any ideas ?
 

Bladimir Carrillo

Member
Licensed User
Longtime User
Can you post the code of ConnectNavigationBar? Run it in debug mode to see the exact error line.

code of ConnectNavigationBar:
B4X:
Sub ConnectNavigationBar(page As ABMPage)
   ' Clear the dummies we created in BuildNavigationBar
   page.NavigationBar.Clear
   If page.ws.Session.GetAttribute("IsAuthorized") = "true" Then
     page.NavigationBar.AddSideBarItem("LogOff", DB.smVar(page,5), "mdi-action-lock-open", "../LoginPage/sismac-login.html")

     page.NavigationBar.AddSideBarItem("ST_Lst", "Consultar solicitudes", "mdi-action-search", "../ST_List/st_list.html")
     page.NavigationBar.AddSideBarDivider("")

     page.NavigationBar.AddSideBarItem("ST_Nue", "Nueva solicitud", "mdi-content-add-circle-outline", "../ST_Edit/st_edit.html")
     page.NavigationBar.AddSideBarDivider("")

   Else
     page.NavigationBar.AddSideBarItem("LogOn", "Iniciar sesión", "mdi-action-lock-outline", "../LoginPage/sismac-login.html")
   End If
   page.NavigationBar.AddSideBarDivider("")
    
End Sub

I am testing in debug mode and the error do not appears; appears sporadically on release mode.

Similar error is showing in other Sub ...

On this case, considering the portion of code ...
Caused by: java.lang.NullPointerException
at sts.sismac.net.loginpage._msbtn1_clicked(loginpage.java:254)

Code of msbtn1_clicked on loginpage:
B4X:
Sub msbtn1_Clicked(Target As String)
   page.Pause
  
   Dim inpUser As ABMInput = page.Component("inpuser")
   Dim inpPass As ABMInput = page.Component("inppass")
   Dim inpCc As ABMInput = page.Component("inpcc")

   Dim jStr As JStringFunctions
   jStr.Initialize

   Dim Nm_Usr As String = inpUser.Text
   Dim Pw_Usr As String = DB.SHA2(inpPass.Text)
   Dim Id_CCs As Long = jStr.Val(inpCc.Text) +10000

   Dim usrSQL As SQL = DB.pool.GetConnection

   Try
     Dim qry As String = $"SELECT um.ID_Usr idm, up.ID_Usr id, up.ID_UsrMod md, up.Nm_Usr us, up.ID_Empl em, e.Nomb1 nm, e.Apell1 ap, e.ID_Dpto dp, e.ID_Secc sc
               FROM Users um,
               SM_Usr up INNER JOIN Pers e ON up.ID_Empl=e.ID_Empl
               WHERE up.Nm_Usr = ? AND up.Pw_Usr = ? AND um.ID_Usr = ?"$

     Dim m As Map = DBUtils.ExecuteMap(usrSQL, qry, Array As String(Nm_Usr,Pw_Usr,Id_CCs))

     usrSQL.Close
    
   Catch
     usrSQL.Close
     Log(LastException)
     page.Resume
     Return
   End Try

   Dim pwInit as String = "1m2nb3jh3i2 3k12hk3jhkrh2 k3jhrk32jrh k3jhrk2j3hrkb3"
   If m.IsInitialized = True Then
     If Pw_Usr = pwInit Then
       DB.smVar_Set(page,2,"" & m.Get("us"))
       DB.smVar_Set(page,5,"" & m.Get("nm") &  " " & m.Get("ap"))
       ABMShared.NavigateToPage(ws, "../" & RsetpwdPage)

     Else
       ws.Session.SetAttribute("IsAuthorized", "true")
       ws.Session.SetAttribute("authType", "local")
       ws.Session.SetAttribute("authName", inpUser.Text)

       ABMShared.NavigateToPage(ws, "../" & InitialPage)
     End If
    Log("LOGIN OK")

   Else
     Log("LOGIN X")

   End If
  
   page.Resume
End Sub

Regards
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Could you please prefix your issues with [ABMaterial] when appropriate?

I look at (study) these posts to see what others find - and learn. Without the prefix, I don't know if you are talking about standard B4J or ABM - or both and may miss an important post...

I need all the knowledge I can get, cause this can get tricky - fast...

Thanks my friend.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
So does mine, so I see your point. More ABM and less B4J. Thanks.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
In ConnectNavigationBar() build in an extra (log) check to see if page.ws <> null. Could be useul info.
Sorry, is this responding to the correct post?

Disregard this comment...
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
This may be the cause of several problems you encounter (loops, sessions lost, slow connections):

It appears in the latest version I did add the b4j_ws.min.js to the core.min.js library. The result was sessioncreator was NEVER used. It was first noticed on Apple devices (loops in reloading) and once I've split them up again, ABMSessionCreator was used and everything is fine. Maybe on slow connections, it does something similar (not getting the right GetSession). Will be changed back in 2.00.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…