B4J Question [Supabase] [SOLVED] Initialization error

yiankos1

Well-Known Member
Licensed User
Longtime User
Good morning team,

Everything was working fine until i uploaded realeased jserver to VPS (fresh install). jServer was starting normally and webapp was visible but connection to supabase was unavailable. So i checked log files and here are the results:
B4X:
SupabaseAuth: User is logged out, this user must log in again
The user has logged out
SupabaseAuth: User is logged out, this user must log in again
The user has logged out
loading C:\Users\Yiankos\Desktop\Projects\B4J\B4J-SE~4\Objects: copymewithjar.needs...
Using cache system: 3.0
Current App version: 1711010777473
Needs material/awesome icons
GZipping HTML, JavaScript and CSS files...
Optimizing new and updated PNG files...
Building core.min.1711010777473.css...
2024-03-21 10:47:26.568:INFO :oejs.Server:main: jetty-11.0.9; built: 2022-03-30T17:44:47.085Z; git: 243a48a658a183130a8c8de353178d154ca04f04; jvm 14.0.1+7
2024-03-21 10:47:26.619:INFO :oejss.DefaultSessionIdManager:main: Session workerName=node0
2024-03-21 10:47:26.628:INFO :oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@7530ad9c{/,file:///C:/Users/Yiankos/Desktop/Projects/B4J/B4J-SERVER-PERSONAL-PROJECT/Objects/www/,AVAILABLE}
2024-03-21 10:47:26.630:INFO :oejs.RequestLogWriter:main: Opened C:\Users\Yiankos\Desktop\Projects\B4J\B4J-SERVER-PERSONAL-PROJECT\Objects\logs\b4j-2024_03_21.request.log
2024-03-21 10:47:26.667:INFO :oejs.AbstractConnector:main: Started ServerConnector@5891e32e{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2024-03-21 10:47:26.825:INFO :oejus.SslContextFactory:main: x509=X509@5d0a1059(1,h=[wecreateapps.gr, www.wecreateapps.gr],a=[],w=[]) for Server@485966cc[provider=null,keyStore=file:///C:/Users/Yiankos/Desktop/Projects/B4J/B4J-SERVER-PERSONAL-PROJECT/Objects/keystore,trustStore=null]
2024-03-21 10:47:26.900:INFO :oejs.AbstractConnector:main: Started ServerConnector@11c20519{SSL, (ssl, alpn, h2, http/1.1)}{0.0.0.0:8081}
2024-03-21 10:47:26.910:INFO :oejs.Server:main: Started Server@7d3a22a9{STARTING}[11.0.9,sto=0] @7050ms
2024-03-21 10:47:26.913:INFO :oejs.Server:main: Stopped Server@7d3a22a9{STOPPING}[11.0.9,sto=0]
2024-03-21 10:47:26.916:INFO :oejs.AbstractConnector:main: Stopped ServerConnector@5891e32e{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2024-03-21 10:47:26.920:INFO :oejs.AbstractConnector:main: Stopped ServerConnector@11c20519{SSL, (ssl, alpn, h2, http/1.1)}{0.0.0.0:8081}
2024-03-21 10:47:26.921:INFO :oejsh.ContextHandler:main: Stopped o.e.j.s.ServletContextHandler@7530ad9c{/,file:///C:/Users/Yiankos/Desktop/Projects/B4J/B4J-SERVER-PERSONAL-PROJECT/Objects/www/,STOPPED}
2024-03-21 10:47:26.925:INFO :oejs.Server:main: jetty-11.0.9; built: 2022-03-30T17:44:47.085Z; git: 243a48a658a183130a8c8de353178d154ca04f04; jvm 14.0.1+7
2024-03-21 10:47:26.928:INFO :oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@7530ad9c{/,file:///C:/Users/Yiankos/Desktop/Projects/B4J/B4J-SERVER-PERSONAL-PROJECT/Objects/www/,AVAILABLE}
2024-03-21 10:47:26.929:INFO :oejs.RequestLogWriter:main: Opened C:\Users\Yiankos\Desktop\Projects\B4J\B4J-SERVER-PERSONAL-PROJECT\Objects\logs\b4j-2024_03_21.request.log
2024-03-21 10:47:26.929:INFO :oejss.DefaultSessionIdManager:main: Session workerName=node0
2024-03-21 10:47:26.935:INFO :oejs.AbstractConnector:main: Started ServerConnector@5891e32e{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2024-03-21 10:47:27.002:INFO :oejus.SslContextFactory:main: x509=X509@5d99c6b5(1,h=[wecreateapps.gr, www.wecreateapps.gr],a=[],w=[]) for Server@485966cc[provider=null,keyStore=file:///C:/Users/Yiankos/Desktop/Projects/B4J/B4J-SERVER-PERSONAL-PROJECT/Objects/keystore,trustStore=null]
2024-03-21 10:47:27.016:INFO :oejs.AbstractConnector:main: Started ServerConnector@11c20519{SSL, (ssl, alpn, h2, http/1.1)}{0.0.0.0:8081}
2024-03-21 10:47:27.017:INFO :oejs.Server:main: Started Server@7d3a22a9{STARTING}[11.0.9,sto=0] @7157ms
B4X:
main._appstart (java line: 262)
java.lang.RuntimeException: java.lang.ClassCastException: class b4j.example.supabase$_supabaseerror cannot be cast to class b4j.example.supabase$_supabasedatabaseresult (b4j.example.supabase$_supabaseerror and b4j.example.supabase$_supabasedatabaseresult are in unnamed module of loader 'app')
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:140)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at anywheresoftware.b4a.keywords.Common$3.run(Common.java:1118)
    at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:47)
    at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:43)
    at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:180)
    at b4j.example.main._appstart(main.java:262)
    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:564)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at b4j.example.main.main(main.java:28)
Caused by: java.lang.ClassCastException: class b4j.example.supabase$_supabaseerror cannot be cast to class b4j.example.supabase$_supabasedatabaseresult (b4j.example.supabase$_supabaseerror and b4j.example.supabase$_supabasedatabaseresult are in unnamed module of loader 'app')
    at b4j.example.classes$ResumableSub_loadUsers.resume(classes.java:1998)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:156)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
    ... 13 more

main.main (java line: 28)
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassCastException: class b4j.example.supabase$_supabaseerror cannot be cast to class b4j.example.supabase$_supabasedatabaseresult (b4j.example.supabase$_supabaseerror and b4j.example.supabase$_supabasedatabaseresult are in unnamed module of loader 'app')
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:140)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at b4j.example.main.main(main.java:28)
Caused by: java.lang.RuntimeException: java.lang.ClassCastException: class b4j.example.supabase$_supabaseerror cannot be cast to class b4j.example.supabase$_supabasedatabaseresult (b4j.example.supabase$_supabaseerror and b4j.example.supabase$_supabasedatabaseresult are in unnamed module of loader 'app')
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:140)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at anywheresoftware.b4a.keywords.Common$3.run(Common.java:1118)
    at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:47)
    at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:43)
    at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:180)
    at b4j.example.main._appstart(main.java:262)
    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:564)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    ... 2 more
Caused by: java.lang.ClassCastException: class b4j.example.supabase$_supabaseerror cannot be cast to class b4j.example.supabase$_supabasedatabaseresult (b4j.example.supabase$_supabaseerror and b4j.example.supabase$_supabasedatabaseresult are in unnamed module of loader 'app')
    at b4j.example.classes$ResumableSub_loadUsers.resume(classes.java:1998)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:156)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
    ... 13 more

According to logs, at begging of the app there are two tries to get the supabase user("The user has logged out"), even if there is no such a code and that causes these two RuntimeException.

At my local pc everything was working fine(supabase initiliazed correctly) until i tried to find out a way to reproduce it. So, i realised that if you delete the file "supabaseauthtoken.dat" from the project's Object folder and you try release the app/server then throws this error too at my pc.

So, if i understand correctly if there is a fresh install of a release app then connection is unavailable. When i say fresh install, i mean "supabaseauthtoken.dat" does not exists before first run.

In debug mode, if you delete the file before the debug run, throws the same errors but connection is done.

Here is my main's page code:

B4X:
Sub AppStart (Args() As String)

    xSupabase.Initialize("https://*****.supabase.co","******")
    xSupabase.InitializeEvents(Me,"Supabase")
    xSupabase.LogEvents = True
 
    ' the user needs to login
    ABMShared.NeedsAuthorization = True
 
    ' Build the Theme
    ABMShared.BuildTheme("mytheme")
 
    ' create the app
    Dim myApp As ABMApplication
    myApp.Initialize
 
    ' create the pages
    Dim mainPage As ABMMainPage
    mainPage.Initialize
     
    ' add the pages to the app
    myApp.AddPage(mainPage.page)

    ' start the server
    myApp.StartServerHTTP2(srvr,"srvr",port,sslPorts,"keystore","****","****")
    ABMShared.RedirectOutput(File.DirApp, "logs.txt")
 
    #If DEBUG
    ' or just open de browser, no multiple devices
    ABM.ViewerOpen("https://localhost:" & sslPorts & "/" & ABMShared.AppName & "/")
    #End If
 
    StartMessageLoop
End Sub
 
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
n debug mode, if you delete the file before the debug run, throws the same errors
I have deleted the file and start the project and it throws not an error, maybe you need to check if the user is logged in before you call the first database action.
 
Upvote 0

yiankos1

Well-Known Member
Licensed User
Longtime User
B4X:
public Sub BuildPage()
    ' initialize the theme
    BuildTheme
   
    ' initialize this page using our theme
    page.InitializeWithTheme(Name, "/ws/" & ABMShared.AppName & "/" & Name, False, ABMShared.SessionMaxInactiveIntervalSeconds, theme)
    page.ShowLoader=True
    page.PageHTMLName = "index.html"
    page.PageTitle = "Template"
    page.PageDescription = "Template"
    page.PageKeywords = ""
    page.PageSiteMapPriority = ""
    page.PageSiteMapFrequency = ABM.SITEMAP_FREQ_YEARLY
       
    page.ShowConnectedIndicator = True
               
    ' adding a navigation bar
    ABMShared.BuildNavigationBar(page, "Προσωπικό","../images/logo.png", "", "settings", "admins")  
           
    ' create the page grid
    page.AddRows(4,True, "").AddCells12(1,"")
   
    page.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components      
   
    page.AddModalSheetTemplate(BuildEditModalSheet)

End Sub

The problem was at the highlighted line. I was creating a modalsheet where i was calling supabase method.

All BuildPage() subs are called at the beggining.

I have deleted the file and start the project and it throws not an error, maybe you need to check if the user is logged in before you call the first database action.
Again, thank you for your time. It was my fault, because i could not think that BuildPage subs are the inceptions.
 
Upvote 0

yiankos1

Well-Known Member
Licensed User
Longtime User
Sometimes the devil is in the detail
I conclude that, in order to find the solution, you have to create a post in the forum first

BTW, i can't thank you enough for this great lib. The needed time is about the half from jrdc+db
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
I conclude that, in order to find the solution, you have to create a post in the forum first
I feel the same way, sometimes a call to the head of department is enough to find the solution when explaining the problem

BTW, i can't thank you enough for this great lib. The needed time is about the half from jrdc+db
I'm glad to hear that, that's the motivation I need. That was also the idea behind creating this interface.
I really want to solve the issue of push notifications, but I can't manage to install DENO or the other 20 options to use the supabase cli.
 
Upvote 0

yiankos1

Well-Known Member
Licensed User
Longtime User
I'm glad to hear that, that's the motivation I need. That was also the idea behind creating this interface.
I really want to solve the issue of push notifications, but I can't manage to install DENO or the other 20 options to use the supabase cli.
This guide will show you how to send push notifications to your app when a new row is inserted into a table using FCM, Supabase Edge Functions, and database web hooks.
This is a great feature if someday is available.

Moreover, if this issue is not solvable, it can be achieved manually i think so. You can return the inserted row and send it manually with FCM. But this is more a workaround and not an Edge function....

I am not sure if i can help you (because my knowledge in JS is zero) but you can pm anything you want.

Lastly, until now i am not able to publish my webapp with a working connection to supabase... Third day trying....
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
The problem was at the highlighted line. I was creating a modalsheet where i was calling supabase method.
BTW, I'm pretty sure Build_Page is only called to build the files for your page and that this occurs during DEBUG (maybe only the first run) of the ABM application. Therefore, are you sure you want to run DB code there since it would never run again until you modify your ABM application code and run it in DEBUG mode first?
 
Upvote 0

yiankos1

Well-Known Member
Licensed User
Longtime User
Yes you are right about this.

I should put the DB code right before showing this modal.

But, i encounter so many other errors about abmaterial and supabase (post), that i am not sure if both of them can cooperate.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…