Embed firebird 3 on linux with 2.5 installed, failing to create database

295 views
Skip to first unread message

Roberto Vieweg

unread,
Dec 15, 2020, 4:12:48 PM12/15/20
to firebird-java
I'm using firebird 3.0.7 as embedded in my application.
I put all the firebird files at a subdirectory called "firebird".

When my application starts, it forces the "jna.library.path" to "firebird/lib" where is the "libfbclient.so".

At the start of my application, I verify if the database exists (/var/myapp/mydb.fdb).
If it doesn't exists, I call this code to create it for me (path is "/var/myapp/mydb.fdb"):

Path dir = path.getParent();
if (Files.notExists(dir)) {
Files.createDirectories(dir);
}

GDSType type = GDSType.getType("EMBEDDED");
try (FBManager fbManager = new FBManager(type)) {
fbManager.start();
fbManager.createDatabase(path.toAbsolutePath().toString(), null, null);
} catch (Exception e) {
throw new RuntimeException("Falha ao criar a base de dados: " + path, e);
}

But when this code run, it fails with:

        org.firebirdsql.jdbc.FBSQLExceptionInfo: Your user name and password are not defined. Ask your database administrator to set up a Firebird login.

If I change my application to use the same username and password of my Fireibird 2.5 installed it passes but another error occurs because the path (/var/myapp/) isn't owned by "firebird" user/group. So as I concluded that my application is trying to create the .fdb file with the Firebird 2.5 instance instead of use the embedded mode setuped.

How can I solve this? I need to create the database (fdb) using the embedded instance instead of use a pre-installed instance at my environment.

Mark Rotteveel

unread,
Dec 16, 2020, 4:29:48 AM12/16/20
to firebi...@googlegroups.com
The problem is likely that Jaybird tries to load the "fbembed" library
before the "fbclient" library, so probably it loads the libfbembed.so of
your Firebird 2.5 installation before trying the libfbclient.so of your
embedded library. Try adding a symlink libfbembed.so that points to
libfbclient.so in that firebird/lib directory. You can also set system
property jna.debug_load=true to see which libraries JNA tries to load
first.

That said, I don't really have experience with running Firebird embedded
on Linux, and I know there are some difference with how it works on
Windows, so I'm not entirely sure if this combination of having Firebird
2.5 installed and trying to run Firebird 3.0 embedded will work or not.

Mark

Roberto Vieweg

unread,
Dec 16, 2020, 6:07:48 AM12/16/20
to firebird-java
Ok, here we have a problem now.

This is the log of JNA:

dez 16, 2020 8:02:18 AM com.sun.jna.NativeLibrary loadLibrary
INFORMAÇÕES: Looking for library 'fbclient'
dez 16, 2020 8:02:18 AM com.sun.jna.NativeLibrary loadLibrary
INFORMAÇÕES: Adding paths from jna.library.path: /home/jjw/firebird/lib
dez 16, 2020 8:02:18 AM com.sun.jna.NativeLibrary loadLibrary
INFORMAÇÕES: Trying libfbclient.so
dez 16, 2020 8:02:18 AM com.sun.jna.NativeLibrary loadLibrary
INFORMAÇÕES: Loading failed with message: libfbclient.so: cannot open shared object file: No such file or directory
dez 16, 2020 8:02:18 AM com.sun.jna.NativeLibrary loadLibrary
INFORMAÇÕES: Adding system paths: [/usr/lib/x86_64-linux-gnu, /lib/x86_64-linux-gnu, /usr/lib64, /lib64, /usr/lib, /lib]
dez 16, 2020 8:02:18 AM com.sun.jna.NativeLibrary loadLibrary
INFORMAÇÕES: Trying /usr/lib64/libfbclient.so
dez 16, 2020 8:02:18 AM com.sun.jna.NativeLibrary loadLibrary
INFORMAÇÕES: Found library 'fbclient' at /usr/lib64/libfbclient.so


The problem is that I have the libfbclient.so:

ls firebird/lib -lha

total 1,9M
drwxr-xr-x 2 root root 4,0K dez 15 18:03 .
drwxr-xr-x 6 root root 4,0K dez 15 18:03 ..
lrwxrwxrwx 1 root root   33 dez 15 18:03 libfbclient.so -> firebird/lib/libfbclient.so.3.0.7
lrwxrwxrwx 1 root root   33 dez 15 18:03 libfbclient.so.2 -> firebird/lib/libfbclient.so.3.0.7
-rw-r--r-- 1 root root 1,9M dez 15 18:03 libfbclient.so.3.0.7
lrwxrwxrwx 1 root root   33 dez 15 18:03 libfbembed.so -> firebird/lib/libfbclient.so.3.0.7
-rw-r--r-- 1 root root 4,3K dez 15 18:03 libib_util.so

So the question is, why it doesn't load my lib ?

Roberto Vieweg

unread,
Dec 16, 2020, 6:17:26 AM12/16/20
to firebird-java
My symbolic links was broken, I fixed them...but now I'm getting another error:


dez 16, 2020 8:11:09 AM com.sun.jna.NativeLibrary loadLibrary
INFORMAÇÕES: Looking for library 'fbembed'
dez 16, 2020 8:11:09 AM com.sun.jna.NativeLibrary loadLibrary
INFORMAÇÕES: Adding paths from jna.library.path: /home/jjw/firebird/lib
dez 16, 2020 8:11:09 AM com.sun.jna.NativeLibrary loadLibrary
INFORMAÇÕES: Trying /home/jjw/firebird/lib/libfbembed.so
dez 16, 2020 8:11:09 AM com.sun.jna.NativeLibrary loadLibrary
INFORMAÇÕES: Loading failed with message: libtommath.so.0: cannot open shared object file: No such file or directory
dez 16, 2020 8:11:09 AM com.sun.jna.NativeLibrary loadLibrary
INFORMAÇÕES: Adding system paths: [/usr/lib/x86_64-linux-gnu, /lib/x86_64-linux-gnu, /usr/lib64, /lib64, /usr/lib, /lib]
dez 16, 2020 8:11:09 AM com.sun.jna.NativeLibrary loadLibrary
INFORMAÇÕES: Trying /home/jjw/firebird/lib/libfbembed.so
dez 16, 2020 8:11:09 AM com.sun.jna.NativeLibrary loadLibrary
INFORMAÇÕES: Loading failed with message: libtommath.so.0: cannot open shared object file: No such file or directory
dez 16, 2020 8:11:09 AM com.sun.jna.NativeLibrary loadLibrary
INFORMAÇÕES: Looking for version variants
dez 16, 2020 8:11:09 AM com.sun.jna.Native extractFromResourcePath
INFORMAÇÕES: Looking in classpath from org.springframework.boot.loader.LaunchedURLClassLoader_53d8d10a for fbembed
dez 16, 2020 8:11:09 AM com.sun.jna.NativeLibrary loadLibrary

I think some "dependencies" are missing (libtommath.so.0) ?! Is it correct? How to fix them?

Roberto Vieweg

unread,
Dec 16, 2020, 6:58:04 AM12/16/20
to firebird-java
I was able to run my app installing:

    apt install libtommath1

Even after installing this lib, I had to create symbolic link to it:

    ln -l firebird/lib/libtommath.so.0 /usr/lib/x86_64-linux-gnu/libtommath.so.1

I also checked the firebird install.sh script, I found another required dependency: libicudata.so (libicu60 package).
This was already installed on my ubuntu 18.04....

The big question now is... this will broke all my running applications on my customers environments.
I'll need to manually install this deps on each one due to this new version of my app (my app is migrating from H2Database to Firebird 3 embedded).

There is no "silver bullet" to solve this, correct?

Roberto Vieweg

unread,
Dec 17, 2020, 8:33:55 AM12/17/20
to firebird-java

I finally finished my project to embed the firebird for windows and linux (32 and 64 bits).

For my needs I also embedded the dependencies (i386 and amd64) like:

I tested in debian and fedora servers, and work fine!

Here is the project, have fun!




Mark Rotteveel

unread,
Dec 17, 2020, 11:49:26 AM12/17/20
to firebi...@googlegroups.com
On 2020-12-16 12:58, Roberto Vieweg wrote:
> I was able to run my app installing:
>
> apt install libtommath1
>
> Even after installing this lib, I had to create symbolic link to it:
>
> ln -l firebird/lib/libtommath.so.0
> /usr/lib/x86_64-linux-gnu/libtommath.so.1
>
> I also checked the firebird install.sh script, I found another
> required dependency: libicudata.so (libicu60 package).
> This was already installed on my ubuntu 18.04....
>
> The big question now is... this will broke all my running applications
> on my customers environments.
> I'll need to manually install this deps on each one due to this new
> version of my app (my app is migrating from H2Database to Firebird 3
> embedded).
>
> There is no "silver bullet" to solve this, correct?

Unfortunately I'm not a Linux expert, and I don't know all the ins and
outs of loading libraries on Linux. On Windows it is a question of
making sure all the necessary DLLs are in the same directory as
fbclient.dll, but I'm not sure if that also applies to Linux, and
unfortunately right now, I don't have the time to experiment.

Mark
Reply all
Reply to author
Forward
0 new messages