B4J Question Application not running on Linux

Fabrice La

Active Member
Licensed User
Longtime User
I am using SQLite to record user data Username, Password, ..
Password are crypted using HexCrypt module.

In Windows it is fine

If I take the the jar file to linux.
Exception in runnable
java.lang.RuntimeException: java.nio.BufferUnderflowException
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:113)
at anywheresoftware.b4a.BA$2.run(BA.java:162)
at com.sun.javafx.application.PlatformImpl$4$1.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl$4$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$4.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.gtk.GtkApplication.enterNestedEventLoopImpl(Native Method)
at com.sun.glass.ui.gtk.GtkApplication._enterNestedEventLoop(Unknown Source)
at com.sun.glass.ui.Application.enterNestedEventLoop(Unknown Source)
at com.sun.glass.ui.EventLoop.enter(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumToolkit.enterNestedEventLoop(Unknown Source)
at javafx.stage.Stage.showAndWait(Unknown Source)
at anywheresoftware.b4j.objects.Form.ShowAndWait(Form.java:172)
at b4j.example.frmlogin._show(frmlogin.java:224)
at b4j.example.main._loginfirst(main.java:195)
at b4j.example.main._appstart(main.java:131)
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:93)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.start(main.java:33)
at com.sun.javafx.application.LauncherImpl$5.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl$5.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl$4$1.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl$4$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$4.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication$3$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.nio.BufferUnderflowException
at java.nio.Buffer.nextGetIndex(Unknown Source)
at java.nio.DirectByteBuffer.getInt(Unknown Source)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.ReadInt(RandomAccessFile.java:122)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.readHelper(RandomAccessFile.java:346)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.ReadObject(RandomAccessFile.java:335)
at b4j.example.hexcrypt._fromhexastring(hexcrypt.java:58)
at b4j.example.hexcrypt._crypt(hexcrypt.java:34)
at b4j.example.frmlogin._btnok_action(frmlogin.java:83)
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:93)
... 33 more

the program stop just after log("Avant")
B4X:
Dim m As Map
    m = DBUtils.ExecuteMap(Main.BDD, "SELECT * FROM UserLogin WHERE login = ?", _
        Array As String(TFName.Text))
        Log(TFName.Text)
    If m.IsInitialized = False Then
        conx = False
    Else
        conx = True
        frommdp = m.Get("mdp") 'keys are lower cased!
        Log(PasswdF.Text)
        If PasswdF.Text <> "" Then
            Log("Avant")
            mdp = HexCrypt.Crypt("de", frommdp, "CleStructure", TFName.Text)
            Log("Apres")
        Else
            mdp = ""
        End If

.........

Public Sub Crypt(sAction As String, sStrInput As String, sCryptKey As String, sName As String) As String
  sAction = sAction.ToUpperCase
  Select sAction.ToUpperCase
  Case "de".ToUpperCase
      Return FromHexaString(sStrInput, sCryptKey, sName)
  Case "en".ToUpperCase
      Return ToHexaString(sStrInput, sCryptKey, sName)
  End Select
  Return "Rien"
End Sub
Private Sub FromHexaString(sStr As String, sCryptKey As String, sName As String) As String
    Dim sRes As String
    Dim raf As RandomAccessFile
    raf.Initialize(File.DirApp & "/.ndf", sName & ".dat", False)
    sRes = raf.ReadObject(raf.CurrentPosition)
    raf.Close
Return sRes
End Sub
 

Fabrice La

Active Member
Licensed User
Longtime User
The database is found as the TFName.Text is show from it but mdp can't be decrypted.

On the log in linux Log(File.DirAssets) gives AssetsDir ....

Which file do you mean ?
 
Last edited:
Upvote 0

Fabrice La

Active Member
Licensed User
Longtime User
if I skip the part:
mdp = HexCrypt.Crypt("de", frommdp, "CleStructure", TFName.Text)

The rest of the appli run like in windows (read data, write data)
 
Upvote 0

Fabrice La

Active Member
Licensed User
Longtime User
File.DirAssets is a virtual read-only folder. You shouldn't use RandomAccessFile with this folder.

I am not using File.DirAsset in my code for Crypt :

B4X:
Dim raf As RandomAccessFile
    raf.Initialize(File.DirApp & "/.ndf",sName & ".dat",False)
    raf.WriteObject(sStr,True,raf.CurrentPosition)
    raf.Close
    Dim TR As TextReader
    TR.Initialize(File.OpenInput(File.DirApp & "/.ndf",sName & ".dat"))
 
Upvote 0
Top