Hi everyone,
I have this code:
The sFile variable is in the form "subfolder/filename.jpg".
The mU.Get("URL") is in the form "https://www.server1.com/"
The line [ wait for (hj) JobDone(job As HttpJob) ] is in line 879.
The functions in CommonFunctions2 are the following:
The code starts at line 862 and ends in line 901. I add a breakpoint in line
and then when I continue running the code I get this error:
The application runs in debug mode...
As you can see the error appears in line 273 where there is no httpjob at all. Any suggestions?
Furthermore when I click in the line where it says error in line 273 it doesn't get me to this line.
My previous version was 7.80 and just today I upgraded to version 9. Am I missing something important here?
I have this code:
B4X:
Dim jp As JSONParser
jp.Initialize(sRes)
Dim mU As Map
mU.Initialize
mU = jp.NextObject
Dim su As StringUtils
For Each k As String In mU.Keys
If k.StartsWith("file") Then
Dim sFile As String = su.DecodeUrl(mU.Get(k), "UTF8")
If File.Exists(rp.GetSafeDirDefaultExternal("Dnlds"), sFile.SubString(sFile.indexof("/") + 1)) Then
'
Else
Dim hj As HttpJob
hj.Initialize("", Me)
hj.Download(su.DecodeUrl(mU.Get("URL"), "UTF8") & sFile)
Log(su.DecodeUrl(mU.Get("URL"), "UTF8") & sFile)
wait for (hj) JobDone(job As HttpJob)
If job.Success Then
Dim b() As Byte = CommonFunctions2.GetByteArrayFromInputStream(job.GetInputStream)
CommonFunctions2.BytesToFile(rp.GetSafeDirDefaultExternal("Dnlds"), sFile.SubString(sFile.indexof("/") + 1), b)
Else
Dim hj2 As HttpJob
hj2.Initialize("", Me)
hj2.Download("http://www.server2.com/images/" & sFile.SubString(sFile.indexof("/") + 1))
wait for (hj2) JobDone(job2 As HttpJob)
If job2.Success Then
Dim b() As Byte = CommonFunctions2.GetByteArrayFromInputStream(job.GetInputStream)
CommonFunctions2.BytesToFile(rp.GetSafeDirDefaultExternal("Guide"), sFile.SubString(sFile.indexof("/") + 1), b)
Else
'
End If
job2.Release
hj2.Release
End If
job.Release
hj.Release
End If
End If
Next
The sFile variable is in the form "subfolder/filename.jpg".
The mU.Get("URL") is in the form "https://www.server1.com/"
The line [ wait for (hj) JobDone(job As HttpJob) ] is in line 879.
The functions in CommonFunctions2 are the following:
B4X:
Sub BytesToFile (Dir As String, FileName As String, Data() As Byte)
Dim out As OutputStream = File.OpenOutput(Dir, FileName.ToLowerCase, False)
out.WriteBytes(Data, 0, Data.Length)
out.Close
End Sub
Sub GetByteArrayFromInputStream(ins As InputStream) As Byte()
Return Bit.InputStreamToBytes(ins)
End Sub
The code starts at line 862 and ends in line 901. I add a breakpoint in line
B4X:
Dim sFile As String = su.DecodeUrl(mU.Get(k), "UTF8")
ResponseError. Reason: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found., Response:
Error occurred on line: 273 (HttpJob)
java.io.FileNotFoundException: /data/user/0/dhqi.trial2.project/cache/3 (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:214)
at dhqi.trial2.project.httpjob._getinputstream(httpjob.java:167)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
java.lang.RuntimeException: Unable to create service dhqi.trial2.project.starter: java.lang.RuntimeException: java.net.SocketException: Socket closed
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3544)
at android.app.ActivityThread.-wrap6(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1732)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
Caused by: java.lang.RuntimeException: java.net.SocketException: Socket closed
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:164)
at anywheresoftware.b4a.shell.Shell.start(Shell.java:102)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
at dhqi.trial2.project.starter.onCreate(starter.java:34)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3534)
... 8 more
Caused by: java.net.SocketException: Socket closed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:151)
at java.net.SocketInputStream.read(SocketInputStream.java:120)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
at java.io.DataInputStream.readInt(DataInputStream.java:387)
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:136)
... 12 more
Error occurred on line: 273 (HttpJob)
java.io.FileNotFoundException: /data/user/0/dhqi.trial2.project/cache/3 (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:214)
at dhqi.trial2.project.httpjob._getinputstream(httpjob.java:167)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
java.lang.RuntimeException: Unable to create service dhqi.trial2.project.starter: java.lang.RuntimeException: java.net.SocketException: Socket closed
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3544)
at android.app.ActivityThread.-wrap6(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1732)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
Caused by: java.lang.RuntimeException: java.net.SocketException: Socket closed
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:164)
at anywheresoftware.b4a.shell.Shell.start(Shell.java:102)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
at dhqi.trial2.project.starter.onCreate(starter.java:34)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3534)
... 8 more
Caused by: java.net.SocketException: Socket closed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:151)
at java.net.SocketInputStream.read(SocketInputStream.java:120)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
at java.io.DataInputStream.readInt(DataInputStream.java:387)
at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:136)
... 12 more
The application runs in debug mode...
As you can see the error appears in line 273 where there is no httpjob at all. Any suggestions?
Furthermore when I click in the line where it says error in line 273 it doesn't get me to this line.
My previous version was 7.80 and just today I upgraded to version 9. Am I missing something important here?