Hello,
I try to transfers files to a server using SMB. I was told that B4X pages is the way to go, targetSdkVersion="34", no DisableStrictMode. I'm trying for several weeks now, but it seems to be impossible. The last code, which caused an Error similar to many other solutions I tried, was for a small program to try to focus better on the problem. It uses additional libraries: jcifs-ng-2.1.9 slf4j-api-1.7.25 bcprov-jdk15on-1.68 bcpkix-jdk15on-1.68 commons-logging-1.2
The code in starter was::
The error-message/log-file was :
Button geklickt – starte SMB-Kontext.
Fordere Starter auf, den SMB-Kontext aufzubauen...
Starte SMB-Kontext-Thread
java.lang.Exception: Sub smbkontextrunnable_event signature does not match expected signature.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:223)
at anywheresoftware.b4a.BA$2.run(BA.java:395)
at android.os.Handler.handleCallback(Handler.java:959)
.....
java.lang.RuntimeException: java.lang.Exception: Sub smbkontextrunnable_event signature does not match expected signature.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:258)
at anywheresoftware.b4a.BA$2.run(BA.java:395)
...
Caused by: java.lang.Exception: Sub smbkontextrunnable_event signature does not match expected signature.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:223)
... 9 more
I tried also inline Java, until now without success. My question: Is there a "legal" way to transfer files via SMBat presnt? Are there examples available? I found several examples, but they do not work without using some trick like DisableStrictMode.
Kind regards Dirk
I try to transfers files to a server using SMB. I was told that B4X pages is the way to go, targetSdkVersion="34", no DisableStrictMode. I'm trying for several weeks now, but it seems to be impossible. The last code, which caused an Error similar to many other solutions I tried, was for a small program to try to focus better on the problem. It uses additional libraries: jcifs-ng-2.1.9 slf4j-api-1.7.25 bcprov-jdk15on-1.68 bcpkix-jdk15on-1.68 commons-logging-1.2
The code in starter was::
B4X:
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
Public smbContext As JavaObject
Public smbBenutzer As String = "________"
Public smbPasswort As String = "*******"
End Sub
Sub Service_Create
Log("🔧 Starter.Service_Create")
' Kein automatischer Aufruf hier!
End Sub
Sub Service_Start (StartingIntent As Intent)
Log("ℹ️ Starter.Service_Start")
Service.StopAutomaticForeground
End Sub
' Wird z. B. über Button in MainPage aufgerufen
Public Sub StarteSMBKontextThread
Log("▶️ Starte SMB-Kontext-Thread")
Dim joMe As JavaObject = Me
Dim runnable As Object = joMe.CreateEvent("java.lang.Runnable", "SMBKontextRunnable", Null)
Dim t As JavaObject
t.InitializeNewInstance("java.lang.Thread", Array(runnable))
t.RunMethod("start", Null)
End Sub
Sub SMBKontextRunnable_Event ' ❗ KEIN Parameter erlaubt
Try
Log("🔧 SMBKontextRunnable: Aufbau startet...")
Dim baseContext As JavaObject
baseContext.InitializeStatic("jcifs.context.BaseContext")
Dim config As JavaObject
config.InitializeNewInstance("jcifs.config.PropertyConfiguration", Array(Null))
Dim credentials As JavaObject
credentials.InitializeNewInstance("jcifs.smb.NtlmPasswordAuthenticator", Array(smbBenutzer, smbPasswort))
Dim instance As JavaObject = baseContext.RunMethod("getInstance", Null)
Dim context As JavaObject = instance.RunMethod("withCredentials", Array(credentials))
smbContext = context
Log("✅ SMB-Kontext aufgebaut.")
CallSubDelayed2(Me, "ErzeugeSMBKontextFertig", True)
Catch
Log("❌ Fehler beim SMB-Kontextaufbau: " & LastException)
CallSubDelayed2(Me, "ErzeugeSMBKontextFertig", False)
End Try
End Sub
Public Sub ErzeugeSMBKontextFertig(success As Boolean)
If success Then
Log("📦 SMB-Kontext wurde erfolgreich aufgebaut.")
Else
Log("⚠️ SMB-Kontext-Aufbau fehlgeschlagen.")
End If
End Sub
The error-message/log-file was :



java.lang.Exception: Sub smbkontextrunnable_event signature does not match expected signature.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:223)
at anywheresoftware.b4a.BA$2.run(BA.java:395)
at android.os.Handler.handleCallback(Handler.java:959)
.....
java.lang.RuntimeException: java.lang.Exception: Sub smbkontextrunnable_event signature does not match expected signature.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:258)
at anywheresoftware.b4a.BA$2.run(BA.java:395)
...
Caused by: java.lang.Exception: Sub smbkontextrunnable_event signature does not match expected signature.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:223)
... 9 more
I tried also inline Java, until now without success. My question: Is there a "legal" way to transfer files via SMBat presnt? Are there examples available? I found several examples, but they do not work without using some trick like DisableStrictMode.
Kind regards Dirk