B4J Question Access denied for temp files when communicating between client and server

markm

Member
Licensed User
Longtime User
I've built a server using jServer to do some basic data housekeeping. I'm building client that needs offline capabilities so it has its own SQLite DB. I'm trying to download the data from a table on the server to a table on the client. When I test, I see in the console log that the request is being made but then the client errors. I'm getting the following error: "(FileNotFoundException) java.io.FileNotFoundException: C:\Users\<logged in user>\AppData\Local\Temp (Access is denied)"

This happens running the server in release and in debug.

On the Client, I am calling:

Client Side:
Sub RequestData (jobname As String) As Object
    'jobname is the data requested from the server such as GetDevices = Get list of all devices from server
    Dim ser As B4XSerializator
    Dim j As HttpJob
    Dim t As Task
    url = Settings.url
    t.Initialize
    t.TaskName = jobname
    t.ToDo = Null
    j.Initialize(jobname, Me)
    j.PostBytes(url, ser.ConvertObjectToBytes(t))
    Dim buffer(j.GetInputStream.BytesAvailable) As Byte
    j.GetInputStream.ReadBytes(buffer, 0, buffer.Length)
    Return ser.ConvertBytesToObject(buffer)
End Sub

On the server side, I've stripped down the handler so it's just trying to send the data and I still get the access denied error:

Server Side:
Sub Handle(req As ServletRequest, resp As ServletResponse)
    Dim buffer(req.InputStream.BytesAvailable) As Byte
    req.InputStream.ReadBytes(buffer, 0, buffer.Length)
    Dim request As Task
    request = serializator.ConvertBytesToObject(buffer)
Log("Request received")   
    If request.TaskName = ("GetDevices") Then       
        Dim bytes() As Byte = serializator.ConvertObjectToBytes(ProcessRequest(request))
        resp.OutputStream.WriteBytes(bytes, 0,bytes.Length )
    else if request.TaskName.StartsWith("Add") Then   
        
    End If    
End Sub

I'm coding on a Windows 10 system, signed on user has full rights to the temp directory. What am I missing?
 

markm

Member
Licensed User
Longtime User
Sure, and as always, thanks so much for your help and the awesome software.

It looks like the error is in my job post.
B4X:
Error occurred on line: 273 (HttpJob)
java.lang.reflect.InvocationTargetException
    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.keywords.Common.CallSubDebug(Common.java:455)
    at LOWS.DB.APP.main._mbmain_action(main.java:935)
    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.shell.Shell.runMethod(Shell.java:632)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA$1.run(BA.java:216)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(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$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:134)
    at anywheresoftware.b4a.debug.Debug.CallSubNew(Debug.java:78)
    ... 26 more
Caused by: java.lang.reflect.InvocationTargetException
    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.debug.Debug.CallSub4(Debug.java:115)
    ... 27 more
Caused by: java.io.FileNotFoundException: C:\Users\Mark\AppData\Local\Temp (Access is denied)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:218)
    at LOWS.DB.APP.httpjob._getinputstream(httpjob.java:152)
    at LOWS.DB.APP.settings._requestdata(settings.java:518)
    at LOWS.DB.APP.settings._fillclientid(settings.java:373)
    at LOWS.DB.APP.settings._configure(settings.java:143)
    at LOWS.DB.APP.main._settings_load(main.java:951)
 
Upvote 0

markm

Member
Licensed User
Longtime User
Thanks so much! That's why a second pair of eyes can be so handy. I'd had it there but must have accidentally deleted it when deleting out some other code and just didn't notice it wasn't there.
 
Upvote 0
Top