B4J Question java.io.FileNotFoundException: C:\Users\GRUPOV~1\AppData\Local\Temp\2 (denied)

virpalacios

Active Member
Licensed User
Longtime User
Hi, I am programming a request to a webservice several times in a loop.
The program gave me this error java.io.FileNotFoundException: C:\Users\GRUPOV~1\AppData\Local\Temp\2 (denied). I am using a system administrator account. I am Glad if someone have a insight about this issue. I am attaching the code (It runs when you click directly to it). I am running in a windows server 2016 with administrator rights and running it from the windows task scheduler.

This Issue is very similar to https://www.b4x.com/android/forum/threads/posible-bug-in-b4j-with-poststring.83965

Best Regards

Virgilio
 
Last edited:

virpalacios

Active Member
Licensed User
Longtime User
Call a Webservices several times:
Private Sub Button1_Click
    Dim data As String
    Dim data_list As List
    Dim lineas_registro As List
    Dim requestSoapXML As String
   
    lineas_registro.Initialize
    data_list.Initialize
    data_list =  File.ReadList(File.DirApp, "data.csv")
    lineas_registro.Add("Matnr|OnHand")
    File.WriteList(File.DirApp, "existencia_inventario.csv", lineas_registro)
    Log("Process Started")
    For i = 0 To 10 ' data_list.Size -1
        Dim j As HttpJob
        Dim material_numero As String
        Dim item_list As List
        item_list.Initialize
        j.Initialize("", Me)
        j.Username = "myuser"
        j.Password = "mypassword"
        item_list = Regex.Split(",",data)
        lineas_registro.Clear
        material_numero = item_list.Get(0)
        requestSoapXML =  File.ReadString(File.DirApp, "request.xml")
        requestSoapXML = requestSoapXML.Replace("$MATERIAL$",material_numero)
        requestSoapXML = requestSoapXML.Replace("$CENTRO$","2002")
           
        j.PostString ("http://myipaddress.com:8102/sap/bc/srt/rfc/sap/zdsd_mm_existencia_preventa/300/zdsd_mm_existencia_preventa/zdsd_mm_existencia_preventa", requestSoapXML)
        j.GetRequest.SetContentType("text/xml")
        Wait For (j) JobDone(j As HttpJob)
        If j.Success Then
            Log(j.GetString)
            j.Release
        End If
       
    Next
    Log("Process Finished")
    ExitApplication
End Sub
 
Upvote 0

virpalacios

Active Member
Licensed User
Longtime User
Error Log at Second Loop:
Extrayendo Data de Items Inventario
Process Started
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:Header/><soap-env:Body><n0:ZdsdMmExistenciaPreventaResponse xmlns:n0="urn:sap-com:document:sap:soap:functions:mc-style"><Cantidad>0.0</Cantidad></n0:ZdsdMmExistenciaPreventaResponse></soap-env:Body></soap-env:Envelope>
httputils2service._hc_responsesuccess (java line: 86)
[COLOR=rgb(184, 49, 47)][B]
        java.io.FileNotFoundException: C:\Users\GRUPOV~1\AppData\Local\Temp\2 (Access Denied)
[/B][/COLOR]
        at java.io.FileOutputStream.open0(Native Method)
        at java.io.FileOutputStream.open(Unknown Source)
        at java.io.FileOutputStream.<init>(Unknown Source)
        at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:439)
        at b4j.example.httputils2service._hc_responsesuccess(httputils2service.java:86)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
        at anywheresoftware.b4a.BA$3.run(BA.java:247)
        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(Unknown Source)
 
Last edited:
Upvote 0

virpalacios

Active Member
Licensed User
Longtime User
Hi Erel, thanks for your promptly answer , sure, I am attaching a small but a complete test program, everything is included data.csv and the request.xml.

Best Regards
 

Attachments

  • PruebaBoton.zip
    141.2 KB · Views: 121
Upvote 0

virpalacios

Active Member
Licensed User
Longtime User
CASE SOLVED

Hi Erel, Good News!!!,
The program message was
java.io.FileNotFoundException: C:\Users\GRUPOV~1\AppData\Local\Temp\2 (Access Denied) ,

As I said, this is a windows server 2012 machine , with serveral users, so i tried with other users, however, the program break at 15th iteration (with other user break at second iteration), so I Just Find Offending directory "\2" and renamed it to "\2x" and everything works like a charm. Maybe it is related to autorization schema in windows?. I also read that because I am running a .bat file I need to authorize the cmd command?. But renaming the directory work very fine for me. If someone else have a issue like this, it will be good to add comments to this tread.

Best Regards Erel and have a Good Day
 
Upvote 0

prajinpraveen

Active Member
Licensed User
Longtime User
Came across this issue. To fix multiple temp folders for user sessions, do this

Using Group Policies (best practice)​

  1. Open Group Policy.
  2. In Computer Configuration, Administrative Templates, Windows Components, Terminal Services, Temporary folders, double-click the Do not use temp folders per session setting.
  3. To disable the creation of a separate temporary folder for each terminal server session, click Enabled. To enable the creation of a separate temporary folder for each terminal server session, click Disabled.
  4. Click OK.
 
Upvote 0
Top