Android Question [SOLVED] httputils2service_hc_responsesuccess (B4A line: 74) problem

Alberto SN

Member
Licensed User
Hi!!

I am developing an application that queries the database. Until today, everything worked fine, but now the following error appears:

B4X:
Registro conectado a:  samsung SM-N970F
--------- beginning of crash
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
~w:1004,main,34
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (principal) Create, isFirst = true **
~w:1004,principal,35
** Activity (principal) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
httputils2service_hc_responsesuccess (B4A line: 74)
Dim out As OutputStream = File.OpenOutput(TempFol
java.io.FileNotFoundException: /data/user/0/com.b4a.Fichaje/cache/2: open failed: ENOENT (No such file or directory)
    at libcore.io.IoBridge.open(IoBridge.java:496)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:235)
    at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:448)
    at com.b4a.Fichaje.httputils2service._hc_responsesuccess(httputils2service.java:239)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    at anywheresoftware.b4a.BA$2.run(BA.java:387)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:237)
    at android.app.ActivityThread.main(ActivityThread.java:8016)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
    at libcore.io.Linux.open(Native Method)
    at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
    at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
    at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7893)
    at libcore.io.IoBridge.open(IoBridge.java:482)
    ... 13 more
java.lang.RuntimeException: java.io.FileNotFoundException: /data/user/0/com.b4a.Fichaje/cache/2: open failed: ENOENT (No such file or directory)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:250)
    at anywheresoftware.b4a.BA$2.run(BA.java:387)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:237)
    at android.app.ActivityThread.main(ActivityThread.java:8016)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)
Caused by: java.io.FileNotFoundException: /data/user/0/com.b4a.Fichaje/cache/2: open failed: ENOENT (No such file or directory)
    at libcore.io.IoBridge.open(IoBridge.java:496)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:235)
    at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:448)
    at com.b4a.Fichaje.httputils2service._hc_responsesuccess(httputils2service.java:239)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    ... 8 more
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
    at libcore.io.Linux.open(Native Method)
    at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
    at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
    at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7893)
    at libcore.io.IoBridge.open(IoBridge.java:482)
    ... 13 more

I am using version 10 of b4a.

Can you help me?

Thank you very much.
 

drgottjr

Expert
Licensed User
Longtime User
please show the code relating to the httputils2 download. you ran 2 jobs. one of them (#2) failed.
in general, when something runs fine until today and then doesn't run, something has changed. either on your end or on the other end.
 
Upvote 0

Alberto SN

Member
Licensed User
Are you using OkHttpUtils2 v2.92?
Yes Erel, I'm using 2.92 version

1596560323114.png
 
Upvote 0

Alberto SN

Member
Licensed User
please show the code relating to the httputils2 download. you ran 2 jobs. one of them (#2) failed.
in general, when something runs fine until today and then doesn't run, something has changed. either on your end or on the other end.

Thanks for response.

My app uses two databases, one local and a hosting db.

The first process recover user data in local db, it's called in activity_create.

If user data doesn't was recover, that condition checks it:

B4X:
    If global.ultimoFichaje.Accion = "" Then
        DB.procesarQuery("SELECT * FROM sisfichaje WHERE NoPersona = '" & global.IdPersona & "' ORDER BY anio desc, mes desc, dia desc LIMIT 1","BUSCA_ULTIMO_FICHAJE",Me)
    End If

....

Sub procesarQuery(Query As String, JobName As String, who As Object)
    Dim job As HttpJob
    job.Initialize(JobName, who)
    job.PostString("http://192.168.1.45/intranet/php/procesos/fichaje/procesoDBselect.php", Query)
    job.GetRequest.Timeout = 5000
    job.Release
End Sub

Sub JobDone(Job As HttpJob)
    Try
        ProgressDialogHide
        If Job.Success Then
            Dim res As String
            Try
                res = Job.GetString
            Catch
                res = ""
            End Try

            Dim parser As JSONParser
            parser.Initialize(res)
            If Job.JobName = "BUSCA_ULTIMO_FICHAJE" Then
                Dim uFichaje As List
                uFichaje = parser.NextArray
                Dim m As Map
                m = uFichaje.Get(0)
                global.ultimoFichaje.Dia = m.Get("Dia")
                global.ultimoFichaje.Mes = m.Get("Mes")
                global.ultimoFichaje.Anio = m.Get("Anio")
                global.ultimoFichaje.Hora = m.Get("Hora")
                global.ultimoFichaje.Accion = m.Get("Accion")
            Else if Job.JobName = "INSERT_FICHAJE" Then
                If totalEnBaseDatos = contadorVolcados Then
                    DB.SQL1.ExecQuerySingleResult("DELETE FROM fichaje_local")
                    ToastMessageShow((contadorVolcados + 1) & " registros transferidos", False)
                Else
                    contadorVolcados = contadorVolcados + 1
                End If
            End If
        Else If Job.ErrorMessage <> Null Then
            ToastMessageShow (global.msgErrorTPnoRegistros, True)
        End If
    Catch
        ToastMessageShow (global.msgErrorTPbusquedaCatch, True)
    End Try
    Job.Release
End Sub

After check, must insert, if conection is on, all records in db local to db hosting:

B4X:
volcarDatos
...

Sub volcarDatos
    Try
        Dim Cursor1 As Cursor = DB.SQL1.ExecQuery("SELECT * FROM fichaje_local") 'local DB
        If Cursor1.RowCount > 0 Then
            'Dim contador As Int = 0
            ToastMessageShow(Cursor1.RowCount & " en base de datos", False)
            totalEnBaseDatos = Cursor1.RowCount - 1
            For i = 0 To Cursor1.RowCount - 1
                Dim montajeSelect As String
                
                Cursor1.Position = i
                montajeSelect = "INSERT INTO sisfichaje VALUES (null, " & global.IdPersona & "," & Cursor1.GetString("Dia") & "," & _
                Cursor1.GetString("Mes") & "," & Cursor1.GetString("Anio") & ",'" & Cursor1.GetString("Hora") & "','" & _
                Cursor1.GetString("Accion") & "')"
                
                idFichaje = Cursor1.GetString("IdFichaje")
                
                DB.procesarQuery(montajeSelect, "INSERT_FICHAJE", Me)
            Next
        End If
        Cursor1.Close
    Catch
        ToastMessageShow(global.errorDBhostingInsert, False)
    End Try
End Sub

Another check had put in when the error occurred but it is removed, after that it has not worked again.

Thanks!!!
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
In your sub procesarQuery you are releasing the job. Don't do that there. I'm pretty sure that is causing your error. Since the job is released before JobDone is called, the underlying temporary files associated with that job are gone when JobDone is raised.
 
Upvote 0

Alberto SN

Member
Licensed User
In your sub procesarQuery you are releasing the job. Don't do that there. I'm pretty sure that is causing your error. Since the job is released before JobDone is called, the underlying temporary files associated with that job are gone when JobDone is raised.

Yes!!! you're right!!

I have removed Job.Release and working fine.

Thank you so much OliverA
 
Upvote 0
Top