B4J Question Application crash on httpjob response

Hi everyone, I need help from anyone who has the desire and time to help me.
I have an application that sends a json to a web service via a httpjob and wait for the response (always a json) with a wait for.
On my PC, debug or release, everything works correctly.
On the server machine both the first sending and the first response work, but the response of a possible second sending causes the application crash.
No errors are caught even though there are "try catch" everywhere in the code.
Can someone help me?

This is the code:

sendJson:
Sub inviaJsonMultiplo (js As Object)
    Try
        Dim j As Map
        j=js
        Dim msg As JSONGenerator
        msg.Initialize(j)
        File.WriteString(File.DirApp & "\jsonSend","_order_" & DateTime.now & "_.json",msg.ToPrettyString(2))
        Main.WriteLogInf("json create")

        Dim job As HttpJob
        job.Initialize("job",Me)
        job.PostString(url,msg.ToString)
        job.GetRequest.SetContentType("application/json; charset=utf-8")
        job.GetRequest.SetHeader("Authorization",aut)
        job.GetRequest.Timeout=600000
        Main.WriteLogInf("json send")

        Wait For (job) JobDone(job As HttpJob)
        If job.Success Then
            Main.WriteLogInf("job.success")
            .....................
            ....................
        Else
            Log("connection error")
        End If
    Catch
        Main.WriteLogErr("Exception")
        Main.WriteLogErrWS(LastException)
    End Try
    job.Release
End Sub

The second time it passes through job.success the application crashes and no exception is caught.

For this application I use the library "jOkHttpUtils2 rel 3.03", and I tried to look for solutions on the forum, but I didn't find anything that could help me.

Thanks,
Christian
 
Hi Erel,
thanks for your reply.

Unfortunately I don't have any logs because until the crash the application works correctly; the strange thing (at least in my experience) is that I can't catch the error.
Is there a folder where the b4j logs are saved independently?
On my PC in debug or release mode the application never crashes, it only happens in release mode on the server.

The jdk version in use is the same, 8u301.

App is UI.

Thanks again for your help, I don't know what to try anymore to resolve.

Christian
 
Upvote 0
Hi Erel,
I didn't know about the possibility of inserting the "application_error" sub into the main, and thanks to this I intercepted the error.

This is the error log:

----------------------------------------------------------------------------
Inf 20231228 16:12:29
(FileNotFoundException) java.io.FileNotFoundException: C:\Users\ADMINI~1.PAS\AppData\Local\Temp\2 (Accesso negato)
___________________________________________________________
Inf 20231228 16:12:29
java.io.FileNotFoundException: C:\Users\ADMINI~1.PAS\AppData\Local\Temp\2 (Accesso negato)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:465)
at b4j.example.httputils2service._hc_responsesuccess(httputils2service.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.BA$3.run(BA.java:267)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:185)
at java.lang.Thread.run(Thread.java:748)
---------------------------------------------------------------------------------------------------

On my PC I have no errors from IDE or .jar, and the really strange thing is that the first response on the server is always received, the second time the request is launched it generates the error reported above when receiving the job.success. Always.

The user who launches the .jar is the domain administrator, so he has no problems with credentials.

Do you have any suggestions?

Thank you,
Christian
 
Upvote 0
Hi Erel,
I added that piece of code just after the job declaration and now it works perfectly!

Thank you so much for your precious help!

Happy New Year!
Christian
 
Upvote 0
Top