B4J Question Problem with Httpjob and Java.io.FileNotFoundException

edgar_ortiz

Active Member
Licensed User
Longtime User
Hi,

In a Windows Server 2016, I'm tring to consume a web-service it gives me the following error:
C:\FEL_Server>cd bin

C:\FEL_Server\bin>java.exe @release_java_modules.txt -m b4j/FEL.Server.main
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Posicion : 3935
ID :E4A6EB69-0A94-44A9-A7C0-17069A8AF783
Antes del Wait de: lcCertRequest
httpjob._getstring2 (java line: -1)
java.io.FileNotFoundException: C:\FEL_Server\bin\httptemp\2 (The system cannot find the file specified)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(Unknown Source)
at java.base/java.io.FileInputStream.<init>(Unknown Source)
at b4j/anywheresoftware.b4a.objects.streams.File.OpenInput(Unknown Source)
at b4j/FEL.Server.httpjob._getstring2(Unknown Source)
at b4j/FEL.Server.httpjob._getstring(Unknown Source)
at b4j/FEL.Server.b4xmainpage$ResumableSub_DB_Buscar_Documentos_Listos.resume(Unknown Source)
at b4j/anywheresoftware.b4a.BA.checkAndRunWaitForEvent(Unknown Source)
at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
at b4j/anywheresoftware.b4a.keywords.Common.CallSub4(Unknown Source)
at b4j/anywheresoftware.b4a.keywords.Common.access$0(Unknown Source)
at b4j/anywheresoftware.b4a.keywords.Common$CallSubDelayedHelper.run(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)


C:\FEL_Server\bin>pause
Press any key to continue . . .

Note log: "Antes del Wait de: lcCertRequest"

The code is:
B4X:
Sub Procesar_Documento(ParData As String) As ResumableSub
    Dim lcResultado As Boolean = True
    Dim lcUrl As String
    Dim lcMensaje As String
    Dim lcCertRequest As HttpJob
    Dim lcFileName As String
    Dim lcPosError As Int
    Dim lcCampos()    As String
    '
    Dim lcHayError As String = ""
    '
    FEL_Data    = ""
    lcCampos    = Regex.Split("\|", ParData)
    '
    lcMensaje    = FEL_wsCall
    '
    If FEL_Param = "1020" Then
        lcFileName    = "Log_Send_" & lcCampos(0).Replace("-","_") & ".txt"
        File.WriteString(File.DirApp, lcFileName, lcMensaje)           
    End If
    '
    lcCertRequest.Initialize("",Me)
    HttpUtils2Service.TempFolder = File.Combine(File.DirApp, "httptemp")
    lcCertRequest.PostString(lcUrl, lcMensaje)
    lcCertRequest.GetRequest.SetContentType("text/xml;charset=utf-8")
    '
    If lcCampos(1) = "A" Then
        lcCertRequest.GetRequest.SetHeader("SOAPAction", "Anulacion")
    Else
        lcCertRequest.GetRequest.SetHeader("SOAPAction", "Nuevo")
    End If
    lcCertRequest.GetRequest.Timeout    = 30000
    '
    If lcCertRequest.IsInitialized = False Then
        lcFileName    = "Log_Error_Initialized_" & lcCampos(0).Replace("-","_") & ".txt"
        File.WriteString(File.DirApp, lcFileName, "NO esta inicializado: lcCertRequest")
    End If
    '
    Log("Antes del Wait de: lcCertRequest")
    Wait For (lcCertRequest) JobDone(lcCertRequest As HttpJob)
    If lcCertRequest.Success Then
        Log("lcCertReques = Success")
        '
        FEL_Data    = lcCertRequest.GetString
        Log("Despues de: FEL_Data    = lcCertRequest.GetString")
        Log("Despues de Sleep(1000)")
        FEL_Data    = JS.RunMethod("unescapeEntities",Array(FEL_Data,True))
        FEL_Data    = FEL_Data.Replace($"" "$,$"""$).Replace($" ""$,$"""$)
        '
    Else        ' Fallo el Request
        Log("Fallo lcCertRequest")
        '
        lcResultado    = False
    End If
    '
    lcCertRequest.Release
    '
    Return lcResultado
End Sub

I guess the error is in the 'Wait For', but I do NOT know the reason or the way to fix it

Any help is appreciated

Regards,

Edgar
 
Top