B4J Question [SOLVED]Error relating to B4x Canvas and/or Sqlite

Peter Lewis

Active Member
Licensed User
Longtime User
Hi All

I have developed an app that we are trying to get to work in a development environment on a machine of a programmer working about 70kms away from me. He is helping to port to Android.

So we setup his B4J environment exactly as mine , same additional libs ect. I sent him the zip backup file. The only difference is he is working on a celeron with 8gb Ram and i am working on a i7 with 32Gb RAM.

If I compile the program and send it to him , it works perfectly. If he opens the program source with B4J and runs it then it works up to a certain stage, then crashes. Here is the crash report.

Message Arrived2 Dave447775566/Start++ Dave447775566
Global Game Name Dave447775566
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by anywheresoftware.b4a.objects.B4XCanvas (file:/C:/Program%20Files%20(x86)/Anywhere%20Software/B4J/Libraries/jXUI.jar) to field javafx.scene.canvas.GraphicsContext.path
WARNING: Please consider reporting this to the maintainers of anywheresoftware.b4a.objects.B4XCanvas
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Topic Server/Advert
Payload 1
QOS 2
Retained false
1
18573467
Error occurred on line: 94 (PLAYGAME)
java.sql.SQLException: ResultSet closed
at org.sqlite.RS.checkOpen(RS.java:63)
at org.sqlite.RS.findColumn(RS.java:108)
at org.sqlite.RS.getString(RS.java:317)
at anywheresoftware.b4j.objects.SQL$ResultSetWrapper.GetString(SQL.java:552)
at b4j.quiz.playgame._getquestion(playgame.java:196)
at b4j.quiz.playgame._start(playgame.java:96)

and as I mentioned this works perfectly on my Dev Machine and a compiled version of the program on his machine

Here is the Code where the error occurs

B4X:
Dim sz As ResultSet
    sz = sql1.ExecQuery2("SELECT game_id, position,Question, Answer1, Answer2, Answer3, Answer4, Correct FROM Questions WHERE game_id = ? And position = ?", Array As String(JOINGAME.GLOGame_ID,Q_Number))
    Log(sz.GetString("Question"))

I was more concerned about this message in the error report
WARNING: Please consider reporting this to the maintainers of anywheresoftware.b4a.objects.B4XCanvas
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

This is the code that could be causing this error


B4X:
        Case "Server/Adverts"
           
            PLAYGAME.DownloadImage(PayLoadStr.Trim)


        PLAYGAME.Adstart =DateTime.Now
        PLAYGAME.adString=PayLoadStr.Trim

and this is the code for the Sub that is called from above

B4X:
Sub DownloadImage(Link As String)
    Dim job As HttpJob
    job.Initialize("", Me) 'note that the name parameter is no longer needed.
    job.Download(Link)
    Wait For (job) JobDone(job As HttpJob)
    If job.Success Then
        ImageView1.SetImage (job.GetBitmap) 'replace with iv.Bitmap = job.GetBitmap in B4A / B4i
        Try
        result.ImageView2.SetImage(job.GetBitmap)
        Catch
            Log("No result yet")
            End Try
    End If
    job.Release
End Sub



If you have any ideas, please let me know

Thank you

Peter
 
Last edited:

Peter Lewis

Active Member
Licensed User
Longtime User
Ignore these warnings. They are not related to any problem you encounter.

The error itself happens in GetQuestion and it is related to a closed ResultSet.
That gives me that same 3 lines of code in my Question that is above.

I do not know 1. How that works perfectly when I compile it on my machine but on a different machine, compiles but when it gets to that part, it fails 2. It looks ok to me
 
Last edited:
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
This is the complete Sub , GetQuestion

B4X:
Sub getquestion(Q_Number As Int)
    Dim sz As ResultSet
        gameover=0
    MQTTutils.PostThis2("Server/Advert",Rnd(1,20),2,False)
    lquestion.Text="Question "&ques&"/"&qtyquestions
        
    btn1.xLBL.Color=xui.Color_LightGray
    btn2.xLBL.Color=xui.Color_LightGray
    btn3.xLBL.Color=xui.Color_LightGray
    btn4.xLBL.Color=xui.Color_LightGray
    
    
    Log(Q_Number)
    Log(JOINGAME.GLOGame_ID)
    
    sz = sql1.ExecQuery2("SELECT game_id, position,Question, Answer1, Answer2, Answer3, Answer4, Correct FROM Questions WHERE game_id = ? And position = ?", Array As String(JOINGAME.GLOGame_ID,Q_Number))
    Log(sz.GetString("Question"))
    
    
    dtaquestion.Text=sz.GetString("Question")

    Dim but1 As Int
    Dim but2 As Int
    Dim but3 As Int
    Dim but4 As Int
    
    but1 =Rnd(1,5)
    
    but2 =Rnd(1,5)
        Do While (but2 <> but1) = False
                     but2 = Rnd(1,4)
                    
        Loop
        
    
    but3 =Rnd(1,5)
        Do While (but3 <> but1 And but3 <> but2) = False
                    but3 = Rnd(1,4)
                    
        Loop

    but4 =10-(but1+but2+but3)

    Log(but1)
    Log(but2)
    Log(but3)
    Log(but4)
    
    If but1 =1 Then
        btn1.xLBL.Text=sz.GetString("Answer1")
        answer=1
'       
        End If
        
     If but1 =2 Then
        btn1.xLBL.Text=sz.GetString("Answer2")
    
    End If
        
     If but1 =3 Then
        btn1.xLBL.Text=sz.GetString("Answer3")
    
    End If
        
     If but1 =4 Then
        btn1.xLBL.Text=sz.GetString("Answer4")

        
    End If
    
    If but2 =1 Then
         btn2.xLBL.Text=sz.GetString("Answer1")
    
        answer=2
        End If
     If but2 =2 Then
        btn2.xLBL.Text=sz.GetString("Answer2")

    End If
    
     If but2 =3 Then
        btn2.xLBL.Text=sz.GetString("Answer3")
    
    End If
    
     If but2 =4 Then
        btn2.xLBL.Text=sz.GetString("Answer4")
    
    End If
    
    If but3 =1 Then
        btn3.xLBL.Text=sz.GetString("Answer1")
        answer=3
    
    End If
     If but3 =2 Then
        btn3.xLBL.Text=sz.GetString("Answer2")
    
    End If
     If but3 =3 Then
        btn3.xLBL.Text=sz.GetString("Answer3")
    
    End If
     If but3 =4 Then
        btn3.xLBL.Text=sz.GetString("Answer4")
    
    End If
    
    If but4 =1 Then
        btn4.xLBL.Text=sz.GetString("Answer1")
        answer=4
    
    End If
     If but4 =2 Then
        btn4.xLBL.Text=sz.GetString("Answer2")
    
    End If
    
    If but4 =3 Then
        btn4.xLBL.Text=sz.GetString("Answer3")
    
    End If
     If but4 =4 Then
        btn4.xLBL.Text=sz.GetString("Answer4")
    
    End If
    
    countownleft=DateTime.Now+15000
    countdownTimer
    
    StartTimeQ=DateTime.Now
    
    sz.Close
End Sub
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
Your code is wrong. You must call ResultSet.NextRow before you access the records.
B4X:
Do While ResultSet.NextRow
'work with record
Loop
ResultSet.Close
I tried this on my machine and it did not make any difference, still compiled and still worked perfectly but on the other dev machine it compiled as before but did not display the database fields in the Buttons and the question did not display.

This is what changes I made on that machine . I went through using Teamviewer to that machine and he also cannot see the question or the answers. I tried on one of my machines in my VMWARE and I installed the environment with all the libs and my source and it worked perfectly.

B4X:
Sub getquestion(Q_Number As Int)
    Dim sz As ResultSet
        gameover=0
    MQTTutils.PostThis2("Server/Advert",Rnd(1,20),2,False)
    lquestion.Text="Question "&ques&"/"&qtyquestions
        
    btn1.xLBL.Color=xui.Color_LightGray
    btn2.xLBL.Color=xui.Color_LightGray
    btn3.xLBL.Color=xui.Color_LightGray
    btn4.xLBL.Color=xui.Color_LightGray
    
    
    Log(Q_Number)
    Log("Global Game Name "&JOINGAME.GLOGame_ID)

    sz = sql1.ExecQuery2("SELECT game_id, position,Question, Answer1, Answer2, Answer3, Answer4, Correct FROM Questions WHERE game_id = ? And position = ?", Array As String(JOINGAME.GLOGame_ID,Q_Number))
    
    Do While sz.NextRow
        
    Log(sz.GetString("Question"))
    
    
    dtaquestion.Text=sz.GetString("Question")

    Dim but1 As Int
    Dim but2 As Int
    Dim but3 As Int
    Dim but4 As Int
    
    but1 =Rnd(1,5)
    
    but2 =Rnd(1,5)
        Do While (but2 <> but1) = False
                     but2 = Rnd(1,4)
                    
        Loop
        
    
    but3 =Rnd(1,5)
        Do While (but3 <> but1 And but3 <> but2) = False
                    but3 = Rnd(1,4)
                    
        Loop

    but4 =10-(but1+but2+but3)

    Log(but1)
    Log(but2)
    Log(but3)
    Log(but4)
    
    If but1 =1 Then
        btn1.xLBL.Text=sz.GetString("Answer1")
        answer=1
'       
        End If
        
     If but1 =2 Then
        btn1.xLBL.Text=sz.GetString("Answer2")
    
    End If
        
     If but1 =3 Then
        btn1.xLBL.Text=sz.GetString("Answer3")
    
    End If
        
     If but1 =4 Then
        btn1.xLBL.Text=sz.GetString("Answer4")

        
    End If
    
    If but2 =1 Then
         btn2.xLBL.Text=sz.GetString("Answer1")
    
        answer=2
        End If
     If but2 =2 Then
        btn2.xLBL.Text=sz.GetString("Answer2")

    End If
    
     If but2 =3 Then
        btn2.xLBL.Text=sz.GetString("Answer3")
    
    End If
    
     If but2 =4 Then
        btn2.xLBL.Text=sz.GetString("Answer4")
    
    End If
    
    If but3 =1 Then
        btn3.xLBL.Text=sz.GetString("Answer1")
        answer=3
    
    End If
     If but3 =2 Then
        btn3.xLBL.Text=sz.GetString("Answer2")
    
    End If
     If but3 =3 Then
        btn3.xLBL.Text=sz.GetString("Answer3")
    
    End If
     If but3 =4 Then
        btn3.xLBL.Text=sz.GetString("Answer4")
    
    End If
    
    If but4 =1 Then
        btn4.xLBL.Text=sz.GetString("Answer1")
        answer=4
    
    End If
     If but4 =2 Then
        btn4.xLBL.Text=sz.GetString("Answer2")
    
    End If
    
    If but4 =3 Then
        btn4.xLBL.Text=sz.GetString("Answer3")
    
    End If
     If but4 =4 Then
        btn4.xLBL.Text=sz.GetString("Answer4")
    
    End If
    Loop
    countownleft=DateTime.Now+15000
    countdownTimer
    
    StartTimeQ=DateTime.Now
    
    sz.Close
End Sub

Could it maybe a graphics driver on his computer ? I know it is an old machine.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Technically, you have 3 questions/issues here. That makes it really hard to help you here (since the focus seems to jump from one question to another). Two of the questions seem to be answered:
1) The warnings displayed are just that, warnings. It just means that in a future LTS release of Java (or even one of the intermittent releases that lead up to an LTS version), the current functionality used may not work anymore. The key here is future. Anywhere Software will take care of that issue for you
2) You had a database issue that was unrelated to #1 above and #3 below. I guess that is resolved?
The third seems to be unresolved:
3) You have a display issue. For that you need to create a minimalist application that can reproduce the issue you are having. Strip everything from this minimalist application (no db code, no extra buttons/fields/windows/etc). Once you have such an application and it still has the issues you are experiencing, open another thread, state your issue and give as much information about both computers, including versions of Java used, how application was installed, etc. Then attach the project source to that post.
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
Technically, you have 3 questions/issues here. That makes it really hard to help you here (since the focus seems to jump from one question to another). Two of the questions seem to be answered:
1) The warnings displayed are just that, warnings. It just means that in a future LTS release of Java (or even one of the intermittent releases that lead up to an LTS version), the current functionality used may not work anymore. The key here is future. Anywhere Software will take care of that issue for you
2) You had a database issue that was unrelated to #1 above and #3 below. I guess that is resolved?
The third seems to be unresolved:
3) You have a display issue. For that you need to create a minimalist application that can reproduce the issue you are having. Strip everything from this minimalist application (no db code, no extra buttons/fields/windows/etc). Once you have such an application and it still has the issues you are experiencing, open another thread, state your issue and give as much information about both computers, including versions of Java used, how application was installed, etc. Then attach the project source to that post.
Yes it is just the last one that is still a problem

I will do your suggestion

Thank you
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
Solved the Problem.

It seems like when a MQTT string came in , it had a space before the Game ID Number I was trying to retrieve. So the solution was to trim it before putting into the database for extraction. The Game ID number has a space in front of it.

Thank you for the advise and help
 
Upvote 0
Top