Issue Details (XML | Word | Printable)

Key: JDBC-259
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Mark Rotteveel
Reporter: Martin Mayerhofer
Votes: 1
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Jaybird JCA/JDBC Driver

UnsatisfiedLinkError occurs in libjaybird22_x64.so undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE

Created: 19/Jul/12 08:30 AM   Updated: 21/Feb/13 08:10 PM
Component/s: JNI layer
Affects Version/s: Jaybird 2.2
Fix Version/s: Jaybird 2.2.1, Jaybird 3.0

Time Tracking:
Not Specified

File Attachments: 1. File libjaybird22.so (142 kB)
2. File libjaybird22_x64.so (147 kB)

Environment: Ubuntu 12.04 x64


 Description  « Hide
libjaybird22_x64.so (ver. 2.2.0-release) / libfbembed.so (ver. 2.5.1) is present in the java.library.path and an exception gets thrown when trying to create a database connection to an embedded database

Exception:

Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/rgba/IdeaProjects/TimeAttendant/libjaybird22_x64.so: /home/rgba/IdeaProjects/TimeAttendant/libjaybird22_x64.so: undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1732)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at org.firebirdsql.gds.impl.jni.JniGDSImpl.initJNIBridge(JniGDSImpl.java:63)
at org.firebirdsql.gds.impl.jni.JniGDSImpl.<clinit>(JniGDSImpl.java:24)
at org.firebirdsql.gds.impl.jni.EmbeddedGDSFactoryPlugin.getGDS(EmbeddedGDSFactoryPlugin.java:40)
at org.firebirdsql.gds.impl.GDSFactory.getGDSForType(GDSFactory.java:220)
at org.firebirdsql.jca.FBManagedConnectionFactory.getGDS(FBManagedConnectionFactory.java:114)
at org.firebirdsql.jdbc.AbstractDriver.connect(AbstractDriver.java:124)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at FBConnect.main(FBConnect.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Java Code:

import org.firebirdsql.jdbc.FBResultSet;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class FBConnect {

  public static void main(String[] args) {

    try {
      Class.forName("org.firebirdsql.jdbc.FBDriver").newInstance();
    } catch (ClassNotFoundException ex) {
      ex.printStackTrace();
    } catch (IllegalAccessException ex) {
      ex.printStackTrace();
    } catch (InstantiationException ex) {
      ex.printStackTrace();
    }

    try {
      Connection bd = DriverManager
              .getConnection(
                      "jdbc:firebirdsql:embedded:/home/rgba/IdeaProjects/TimeAttendant/TADATA.FDB",
                      "sysdba", "masterkey");
      Statement st = bd.createStatement();
      FBResultSet rs = (FBResultSet)st.executeQuery("select * from TABLE1");
      while (rs.next()) {
        System.out.print(rs.getString(1));
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

Java VM Version:

java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)

OS:

Ubuntu 12.04


 All   Comments   Work Log   Change History   Version Control   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Mark Rotteveel added a comment - 19/Jul/12 04:45 PM
The problem is most likely caused by a missing libstdc++.so.6 on your machine.
Check if you have libstdc++.so.6 on your machine using
find /usr/ -name libstdc++.so.6

If not, then you should be able to install it using:
apt-get install libstdc++6

Mark Rotteveel added a comment - 19/Jul/12 04:53 PM
BTW: As far as I can tell Jaybird itself does not depend on libstdc++6 (according to the ldd output), so it might be a dependency of Java.

Mark Rotteveel added a comment - 21/Jul/12 01:38 PM - edited
After some further investigating, it seems that the problem is with libjaybird. ldd -r shows that this symbol (and some others) are undefined:

mark@ubuntu-x64:~/development/jaybird/client-java/native$ ldd -r libjaybird22_x64.so
linux-vdso.so.1 => (0x00007fffa9a00000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb4f6548000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fb4f6330000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb4f6b20000)
undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE (./libjaybird22_x64.so)
undefined symbol: __gxx_personality_v0 (./libjaybird22_x64.so)
undefined symbol: _ZTISt9bad_alloc (./libjaybird22_x64.so)
undefined symbol: dlopen (./libjaybird22_x64.so)
undefined symbol: _ZdlPv (./libjaybird22_x64.so)
undefined symbol: _Znam (./libjaybird22_x64.so)
undefined symbol: __cxa_end_catch (./libjaybird22_x64.so)
undefined symbol: __cxa_allocate_exception (./libjaybird22_x64.so)
undefined symbol: dlclose (./libjaybird22_x64.so)
undefined symbol: _ZdaPv (./libjaybird22_x64.so)
undefined symbol: __cxa_begin_catch (./libjaybird22_x64.so)
undefined symbol: __cxa_throw (./libjaybird22_x64.so)
undefined symbol: dlsym (./libjaybird22_x64.so)
undefined symbol: _Znwm (./libjaybird22_x64.so)
undefined symbol: __cxa_free_exception (./libjaybird22_x64.so)

Mark Rotteveel added a comment - 21/Jul/12 02:35 PM
Could you check if the attached version of the library solves the problem for you?

Mark Rotteveel added a comment - 21/Jul/12 02:42 PM
Attached libjaybird22_x64.so was compiled by including <syslibset libs="stdc++,dl"/> into the gcc linker definition in build_native.xml (apparently the already included <linkerarg value="-ldl"/> and <linkerarg value="-lstdc++"/> are ignored).

The ldd output is now good:
mark@ubuntu-x64:~/development/jaybird/client-java$ ldd -r ./output/native/libjaybird22_x64.so
linux-vdso.so.1 => (0x00007fff92b90000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcba09e8000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fcba06e0000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fcba04d8000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fcba02c0000)
/lib64/ld-linux-x86-64.so.2 (0x00007fcba0fc0000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fcba0038000)

Martin Mayerhofer added a comment - 21/Jul/12 03:06 PM
I tried the attached library and the UnsatisfiedLinkError is gone, nevertheless there is another error popping up which also ends in the native library, I have both libfbembed.so + libfbclient.so (both ver. 2.5.1) in my library path.

Exception:

org.firebirdsql.gds.impl.jni.InternalError: FirebirdApiBinding::Initialize - Could not find or load the firebird client library.
at org.firebirdsql.gds.impl.jni.JniGDSImpl.nativeInitilize(Native Method)
at org.firebirdsql.gds.impl.jni.JniGDSImpl.attemptToLoadAClientLibraryFromList(JniGDSImpl.java:92)
at org.firebirdsql.gds.impl.jni.EmbeddedGDSImpl.<init>(EmbeddedGDSImpl.java:31)
at org.firebirdsql.gds.impl.jni.EmbeddedGDSImpl.<init>(EmbeddedGDSImpl.java:21)
at org.firebirdsql.gds.impl.jni.EmbeddedGDSFactoryPlugin.getGDS(EmbeddedGDSFactoryPlugin.java:40)
at org.firebirdsql.gds.impl.GDSFactory.getGDSForType(GDSFactory.java:220)
at org.firebirdsql.jca.FBManagedConnectionFactory.getGDS(FBManagedConnectionFactory.java:114)
at org.firebirdsql.jdbc.AbstractDriver.connect(AbstractDriver.java:124)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at FBConnect.main(FBConnect.java:23)
org.firebirdsql.gds.impl.jni.InternalError: FirebirdApiBinding::Initialize - Could not find or load the firebird client library.
at org.firebirdsql.gds.impl.jni.JniGDSImpl.nativeInitilize(Native Method)
at org.firebirdsql.gds.impl.jni.JniGDSImpl.attemptToLoadAClientLibraryFromList(JniGDSImpl.java:92)
at org.firebirdsql.gds.impl.jni.EmbeddedGDSImpl.<init>(EmbeddedGDSImpl.java:31)
at org.firebirdsql.gds.impl.jni.EmbeddedGDSImpl.<init>(EmbeddedGDSImpl.java:21)
at org.firebirdsql.gds.impl.jni.EmbeddedGDSFactoryPlugin.getGDS(EmbeddedGDSFactoryPlugin.java:40)
at org.firebirdsql.gds.impl.GDSFactory.getGDSForType(GDSFactory.java:220)
at org.firebirdsql.jca.FBManagedConnectionFactory.getGDS(FBManagedConnectionFactory.java:114)
at org.firebirdsql.jdbc.AbstractDriver.connect(AbstractDriver.java:124)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at FBConnect.main(FBConnect.java:23)
java.lang.RuntimeException: Failed to initialize Jaybird native library. This is most likely due to a failure to load the firebird client library.
at org.firebirdsql.gds.impl.jni.JniGDSImpl.attemptToLoadAClientLibraryFromList(JniGDSImpl.java:105)
at org.firebirdsql.gds.impl.jni.EmbeddedGDSImpl.<init>(EmbeddedGDSImpl.java:31)
at org.firebirdsql.gds.impl.jni.EmbeddedGDSImpl.<init>(EmbeddedGDSImpl.java:21)
at org.firebirdsql.gds.impl.jni.EmbeddedGDSFactoryPlugin.getGDS(EmbeddedGDSFactoryPlugin.java:40)
at org.firebirdsql.gds.impl.GDSFactory.getGDSForType(GDSFactory.java:220)
at org.firebirdsql.jca.FBManagedConnectionFactory.getGDS(FBManagedConnectionFactory.java:114)
at org.firebirdsql.jdbc.AbstractDriver.connect(AbstractDriver.java:124)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at FBConnect.main(FBConnect.java:23)

Mark Rotteveel added a comment - 21/Jul/12 03:16 PM
Typical debugging problem :( Solve one problem and another pops up. I will investigate further.

Mark Rotteveel added a comment - 21/Jul/12 04:25 PM
I tried this under Ubuntu 12.04 As far as I can see under Ubuntu 12.04, the libfbembed2.5 package does not create a /usr/lib/libfbembed.so or /usr/lib/x86_64-linux-gnu/libfbembed.so symlink to /usr/lib/x86_64-linux-gnu/libfbembed.so.2.5.1. After adding this symlink manually the library is found.

BTW: I didn't get the original undefined symbol error with the original libjaybird22_x64.so under Ubuntu 12.04. Which Java version do you have installed? I installed openjdk-6-jdk; maybe the errors depend on the exact java version.

Martin Mayerhofer added a comment - 21/Jul/12 04:40 PM - edited
I have following java version installed:

Java VM Version:

java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)

Just to add some more information, I used following libraries:

http://sourceforge.net/projects/firebird/files/firebird-linux-amd64/2.5.1-Release/FirebirdCS-2.5.1.26351-0.amd64.tar.gz/download

edit: corrected libary link

Mark Rotteveel added a comment - 21/Jul/12 05:01 PM - edited
That download is for the Windows 64 Firebird Embedded, which is not going to work under Ubuntu ;)

Could you please check which libfbembed.so files are available on your computer. Most likely you are missing the libfbembed.so symlink itself (that was the problem on my ubuntu 12.04 VM).

I would also like to know which Ubuntu package you installed for Java, as your version info differs from the openjdk-6-jdk I installed using apt-get and that package reports:
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.3) (6b24-1.11.3-1ubuntu0.12.04.1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

Martin Mayerhofer added a comment - 21/Jul/12 05:21 PM
sorry pasted the wrong link, of course the windows version will not work under ubuntu ;)

here is the correct link: http://sourceforge.net/projects/firebird/files/firebird-linux-amd64/2.5.1-Release/FirebirdCS-2.5.1.26351-0.amd64.tar.gz/download

as for the java installation, I downloaded it from oracle: http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html#jdk-6u30-oth-JPR


Mark Rotteveel added a comment - 22/Jul/12 06:40 AM - edited
I expected that you would have used the packages from the Ubuntu 12.04 repository itself. I am not sure if I have time to dive deeper into it this week, and I am on holiday from next Saturday. For the embedded library loading be sure to check that the library (or its symlink) is called libfbembed.so, and that it is in the actual library path (either specified in java.library.path, or ld.so.conf or in LD_LIBRARY_PATH).

With the Firebird embedded library from the Ubuntu repository I had the same(?) problem as it did not have a libfbembed.so library (just a so.2.5 and so.2.5.1).

Paolo added a comment - 26/Jul/12 11:23 AM
I've the same problem in 32 bit system: libjaybird22.so: undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE
ldd -r shows that this symbol (and some others) are undefined.

Is there a build that fixes this problem also for 32 bit system?

uts@uts-desktop:/usr/lib/i686$ ldd -r /home/uts/NetBeansProjects/ladon/lib/win/32/libjaybird22.so
undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE (/home/uts/NetBeansProjects/ladon/lib/win/32/libjaybird22.so)
undefined symbol: __gxx_personality_v0 (/home/uts/NetBeansProjects/ladon/lib/win/32/libjaybird22.so)
undefined symbol: _ZTISt9bad_alloc (/home/uts/NetBeansProjects/ladon/lib/win/32/libjaybird22.so)
undefined symbol: dlopen (/home/uts/NetBeansProjects/ladon/lib/win/32/libjaybird22.so)
undefined symbol: _ZdlPv (/home/uts/NetBeansProjects/ladon/lib/win/32/libjaybird22.so)
undefined symbol: __cxa_end_catch (/home/uts/NetBeansProjects/ladon/lib/win/32/libjaybird22.so)
undefined symbol: __cxa_allocate_exception (/home/uts/NetBeansProjects/ladon/lib/win/32/libjaybird22.so)
undefined symbol: dlclose (/home/uts/NetBeansProjects/ladon/lib/win/32/libjaybird22.so)
undefined symbol: _Znwj (/home/uts/NetBeansProjects/ladon/lib/win/32/libjaybird22.so)
undefined symbol: _ZdaPv (/home/uts/NetBeansProjects/ladon/lib/win/32/libjaybird22.so)
undefined symbol: _Znaj (/home/uts/NetBeansProjects/ladon/lib/win/32/libjaybird22.so)
undefined symbol: __cxa_begin_catch (/home/uts/NetBeansProjects/ladon/lib/win/32/libjaybird22.so)
undefined symbol: __cxa_throw (/home/uts/NetBeansProjects/ladon/lib/win/32/libjaybird22.so)
undefined symbol: dlsym (/home/uts/NetBeansProjects/ladon/lib/win/32/libjaybird22.so)
undefined symbol: __cxa_free_exception (/home/uts/NetBeansProjects/ladon/lib/win/32/libjaybird22.so)
linux-gate.so.1 => (0xb8047000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7ebb000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7eac000)
/lib/ld-linux.so.2 (0xb8048000)


My system is:
Ubuntu 8.10 kernel 2.6.27-11-generic
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing)

Martin Mayerhofer added a comment - 26/Jul/12 11:55 AM
Currently the only solution would be that you compile the natives on your own, including the fix to the build_native.xml which Mark mentioned earlier ...

Mark Rotteveel added a comment - 26/Jul/12 04:54 PM
I will upload a new version of the 32 bit library later today.

Mark Rotteveel added a comment - 26/Jul/12 06:11 PM
Attached correctly linked 32 bit libjaybird22.so

Mark Rotteveel added a comment - 11/Aug/12 08:46 AM
This issue needs to be linked to Version Jaybird 2.2.1 when it is created

Mark Rotteveel added a comment - 11/Aug/12 08:51 AM
Committed fixed build file to trunk and Branch_2_2

Paolo added a comment - 03/Sep/12 10:49 AM
I've set library path to FirebirdCS-2.5.1.26351-0.amd64/buildroot/opt/firebird/lib/libfbclient.so or /opt/firebird/lib (after installing it) or /usr/lib64 but I always have "Could not find or load the firebird client library"

If I statically load library through System.loadlibrary() I've no error.
            System.loadLibrary("icudata");
            System.loadLibrary("icuuc");
            System.loadLibrary("icui18n");
            System.loadLibrary("ib_util");
            System.loadLibrary("fbembed");
            System.loadLibrary("fbclient");

What could be wrong?

My system properties:
Jaybird 2.2
Java 1.7.0_06 64 bit
OS: Ubuntu 12.04 64 bit

Runtime error:

org.firebirdsql.gds.impl.jni.InternalError: FirebirdApiBinding::Initialize - Could not find or load the firebird client library.
at org.firebirdsql.gds.impl.jni.JniGDSImpl.nativeInitilize(Native Method)
at org.firebirdsql.gds.impl.jni.JniGDSImpl.attemptToLoadAClientLibraryFromList(JniGDSImpl.java:92)
at org.firebirdsql.gds.impl.jni.EmbeddedGDSImpl.<init>(EmbeddedGDSImpl.java:31)
at org.firebirdsql.gds.impl.jni.EmbeddedGDSImpl.<init>(EmbeddedGDSImpl.java:21)
at org.firebirdsql.gds.impl.jni.EmbeddedGDSFactoryPlugin.getGDS(EmbeddedGDSFactoryPlugin.java:40)
at org.firebirdsql.gds.impl.GDSFactory.getGDSForType(GDSFactory.java:220)
at org.firebirdsql.jdbc.FBConnectionProperties.getGds(FBConnectionProperties.java:502)
at org.firebirdsql.jdbc.FBConnectionProperties.getDatabaseParameterBuffer(FBConnectionProperties.java:393)
at org.firebirdsql.jca.FBManagedConnectionFactory.getDatabaseParameterBuffer(FBManagedConnectionFactory.java:205)
at org.firebirdsql.jca.FBManagedConnectionFactory.getDefaultConnectionRequestInfo(FBManagedConnectionFactory.java:407)
at org.firebirdsql.pool.AbstractFBConnectionPoolDataSource.allocateConnection(AbstractFBConnectionPoolDataSource.java:265)
at org.firebirdsql.pool.PooledConnectionQueue.addConnection(PooledConnectionQueue.java:491)
at org.firebirdsql.pool.PooledConnectionQueue.start(PooledConnectionQueue.java:155)
at org.firebirdsql.pool.AbstractConnectionPool.getQueue(AbstractConnectionPool.java:205)
at org.firebirdsql.pool.AbstractFBConnectionPoolDataSource.getPooledConnection(AbstractFBConnectionPoolDataSource.java:372)
at org.firebirdsql.pool.FBWrappingDataSource.getConnection(FBWrappingDataSource.java:219)
at com.tecnosens.ladon.dbInterface.DbConnection.connectEmbeddedDS(DbConnection.java:213)