B4J Question B4J Packager additional modules

Discussion in 'B4J Questions' started by yiankos1, Nov 8, 2019 at 10:58 AM.

  1. yiankos1

    yiankos1 Active Member Licensed User

    Hello team,
    I want to distribute an app (with tool b4j packager) that uses additional jar about sqlite connection and encryption.
    Code:
    #AdditionalJar: sqlite-jdbc-3.30.0
        
    #AdditionalJar: bcprov-jdk15on-154
    Do i have to edit IncludedModules at packager code?
    Thank you for your time.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    No.
     
  3. yiankos1

    yiankos1 Active Member Licensed User

    When I try to run after package from temp folder, everything works fine. If I copy to external drive or another pc, if I start exe (debug console) says that can't open sqlite database. I use custom drive for sqlite. Should I wait for 1.41 version of jSQL that will release with next b4j update?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Where was v1.41 mentioned?
     
  5. yiankos1

    yiankos1 Active Member Licensed User

    I am sorry, 1.61. Here
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    It has nothing to do with this thread.
     
  7. yiankos1

    yiankos1 Active Member Licensed User

    I am saying this because I use other driver for sqlite connection, maybe there is a problem when packaging?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    The answer to your question was given in post #2.
    If you encounter any other error then you should post all the relevant information, including the relevant code and full error message.
     
  9. yiankos1

    yiankos1 Active Member Licensed User

    When i run app somewhere else (external drive, other pc) i get this error log when run "run_debug.bat":
    Code:
    D:\temp\build\bin>java.exe @release_java_modules.txt  -m b4j/b4j.example.main
    main._appstart (java line: -
    1)
    java.sql.SQLException: opening db: 
    'file:data.db?cipher=sqlcipher&legacy=1&kdf_iter=4000&key=****': ? ??????? ??? ???????? ???????, ??? ???????? ????????? ? ??? ????????
    ??? ????? ????? ?????????
            at b4j/org.sqlite.Conn.open(Unknown Source)
            at b4j/org.sqlite.Conn.<init>(Unknown Source)
            at b4j/org.sqlite.JDBC.createConnection(Unknown Source)
            at b4j/org.sqlite.JDBC.connect(Unknown Source)
            at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
            at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
            at b4j/anywheresoftware.b4j.objects.SQL.Initialize2(Unknown Source)
            at b4j/anywheresoftware.b4j.objects.SQL.Initialize(Unknown Source)
            at b4j/b4j.example.main._appstart(Unknown Source)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.base/java.lang.reflect.Method.invoke(Unknown Source)
            at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
            at b4j/anywheresoftware.b4a.BA.raiseEvent(Unknown Source)
            at b4j/b4j.example.main.start(Unknown Source)
            at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$
    9(Unknown Source)
            at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$
    12(Unknown Source)
            at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$
    10(Unknown Source)
            at java.base/java.security.AccessController.doPrivileged(Native Method)
            at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$
    11(Unknown Source)
            at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$
    Future.run(Unknown Source)
            at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
            at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$
    3(Unknown Source)
            at java.base/java.lang.Thread.run(Unknown Source)


    D:\temp\build\bin>pause
    Press any key 
    to continue . . .
    my source code:
    Code:
    Sub AppStart (Form1 As Form, Args() As String)
      
        
    DateTime.DateFormat=("dd/MM/yyyy")
                
    SQL.Initialize("org.sqlite.JDBC","jdbc:sqlite:file:data.db?cipher=sqlcipher&legacy=1&kdf_iter=4000&key=*****")
      
        DB.CreateUserTableIfNeeded
      
        login.Show
          
    End Sub
    Code:
    Public Sub CreateUserTableIfNeeded
      
        
    Dim ct As String = ($"CREATE TABLE IF NOT EXISTS users (
        id INTEGER PRIMARY KEY AUTOINCREMENT Not Null,
        username INTEGER (6) UNIQUE ON CONFLICT FAIL Not Null,
        vathmos TEXT,
        epitheto TEXT,
        onoma TEXT,
        hash BLOB Not Null,
        salt BLOB Not Null,
        level INTEGER (1) Not Null)"$
    )
        Main.sql.ExecNonQuery(ct)
      
        ct = (
    $"CREATE TABLE IF NOT EXISTS log (
        id INTEGER PRIMARY KEY AUTOINCREMENT Not Null,
        username INTEGER (6) Not Null,
        last_login TEXT DEFAULT (CURRENT_TIMESTAMP))"$
    )
        Main.sql.ExecNonQuery(ct)
      
        ct = (
    $"CREATE TABLE IF NOT EXISTS registry (
        id                    INTEGER PRIMARY KEY AUTOINCREMENT,
        prot_tmima            TEXT    CONSTRAINT prot_tmima_replace UNIQUE ON CONFLICT REPLACE,
        date_eisagogi         TEXT,
        epitheto              TEXT,
        onoma                 TEXT)"$
    )
        Main.sql.ExecNonQuery(ct)
      
    End Sub
    I use this sqlite driver. I changed my password with ****
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    I've tried it with this code and it works properly:
    Code:
    sql.Initialize("org.sqlite.JDBC",$"jdbc:sqlite:file:${File.Combine(File.DirApp, "data.db").Replace("\""/")}?cipher=sqlcipher&legacy=1&kdf_iter=4000&key=YOURKEY"$)
     
  11. yiankos1

    yiankos1 Active Member Licensed User

    n
    Hello. Thank you for your answer. Now it does not run even at my pc.
    Throws this error
    Code:
    main._appstart (java line: 71)
    java.sql.SQLException: 
    path to 'file:C:/Users/Yiankos/Desktop/WPD/Objects/data.db?cipher=sqlcipher&legacy=1&kdf_iter=4000&key=****': 'C:\Users\Yiankos\Desktop\WPD\Objects\file:C:' does not exist
        at org.sqlite.Conn.open(Conn.java:103)
        at org.sqlite.Conn.<init>(Conn.java:
    57)
        at org.sqlite.JDBC.createConnection(JDBC.java:
    77)
        at org.sqlite.JDBC.connect(JDBC.java:
    64)
        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:
    677)
        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:
    228)
        at anywheresoftware.b4j.objects.SQL.Initialize2(
    SQL.java:57)
        at anywheresoftware.b4j.objects.SQL.Initialize(
    SQL.java:46)
        at b4j.example.main._appstart(main.java:
    71)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
    62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
    43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:
    566)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    91)
        at anywheresoftware.b4a.BA.raiseEvent(BA.java:
    78)
        at b4j.example.main.start(main.java:
    37)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$
    9(LauncherImpl.java:846)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$
    12(PlatformImpl.java:455)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$
    10(PlatformImpl.java:428)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$
    11(PlatformImpl.java:427)
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    Does it work when you run it from the IDE? Are you using Java 11 in the IDE?
     
  13. yiankos1

    yiankos1 Active Member Licensed User

    Yes i use this version:
    Code:
    C:\Program Files\Java\jdk-11.0.1\bin\javac.exe
    Now, It does not run from IDE nor external drive. If i change to my sqlite initialization
    Code:
    SQL.Initialize("org.sqlite.JDBC","jdbc:sqlite:file:data.db?cipher=sqlcipher&legacy=1&kdf_iter=4000&key=****")
    works on IDE but it does not work on external pc.
    Do you need something else in order to help me get this working.
     
  14. Erel

    Erel Administrator Staff Member Licensed User

    The error happens inside the custom SQL driver that you found. I cannot really help you as it doesn't happen here. It might be a bug in this driver.

    You need to make some tests. I've tested it with sqlite-jdbc-3.30.1.

    You should also try other paths.
     
  15. OliverA

    OliverA Expert Licensed User

    This may be a clue. In both of your error message postings, it is java.sql that spits out the error messages. Trying to simulate some error messages on my end, they are as follows
    Notice how in my case it is the org.sqilte driver that is complaining, not the generic java.sql class
    Notes:
    1) As @Erel, I was using 3.30.1 driver version
    2) I've not packaged the test, but it also works from the command line
     
  16. Daestrum

    Daestrum Well-Known Member Licensed User

    It looks more like a permissions problem than code problem. Do you have write permission for the external drive ?
     
  17. DonManfred

    DonManfred Expert Licensed User

    SURE the path is correct???? It looks like the objects folder of your project. There should be NO databasefile!
     
  18. OliverA

    OliverA Expert Licensed User

    Please note, if you don't give the file: URI a path, the default location is File.DirApp. During testing/development, that will be the Objects folder. Quite normal. Plus @Erel's snippet uses File.DirApp (again Objects during development). It's just odd that java.sql produces the error instead of the driver (since the driver is opening the file). Oh yeah, the SQLite driver happily creates a database file when it cannot be found (as long as the path is correct).
     
  19. DonManfred

    DonManfred Expert Licensed User

    Honestly; i was not aware of this.
    thank you for clarifying.
     
    OliverA likes this.
  20. DonManfred

    DonManfred Expert Licensed User

    Probably it is because i always compile in Releasemode instead of debug...
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice