libJdbcOdbc SQLAllocEnv一般是未定义和动态链接

时间:2012-11-20 14:39:29

标签: java jdbc shared-libraries elf

我在运行应用程序时收到消息

java: symbol lookup error: /usr/java/jdk1.7.0_09/jre/lib/amd64/libJdbcOdbc.so: undefined symbol: SQLAllocEnv

应用程序的目的是使用Pentaho kettle jar文件将数据从一个服务器迁移到另一个服务器。我在目标服务器上使用Jdbc-Odbc连接。我最近从Oracles网站安装了java(jre和jdk)。当我设置

export LD_DEBUG=all

我看到以下回复

binding file /usr/java/jdk1.7.0_09/jre/lib/amd64/libJdbcOdbc.so [0] to /lib64/libc.so.6 [0]: normal symbol `__cxa_finalize' [GLIBC_2.2.5]
      5193:
      5193:     calling init: /usr/java/jdk1.7.0_09/jre/lib/amd64/libJdbcOdbc.so
      5193:
      5193:     opening file=/usr/java/jdk1.7.0_09/jre/lib/amd64/libJdbcOdbc.so [0]; direct_opencount=1
      5193:
      5193:     symbol=JNI_OnLoad;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/libJdbcOdbc.so [0]
      5193:     symbol=JNI_OnLoad;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/libjava.so [0]
      5193:     binding file /usr/java/jdk1.7.0_09/jre/lib/amd64/libJdbcOdbc.so [0] to /usr/java/jdk1.7.0_09/jre/lib/amd64/libjava.so [0]: normal symbol `JNI_OnLoad'
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/libjava.so [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/server/libjvm.so [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/libverify.so [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/lib64/libdl.so.2 [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/lib64/libc.so.6 [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/lib64/libm.so.6 [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/lib64/libpthread.so.0 [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
      5193:     /usr/java/jdk1.7.0_09/jre/lib/amd64/libjava.so: error: symbol lookup error: undefined symbol: Java_sun_jdbc_odbc_JdbcOdbc_allocEnv (fatal)
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/libzip.so [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/server/libjvm.so [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/libjava.so [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/lib64/libc.so.6 [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/lib64/libm.so.6 [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/lib64/libdl.so.2 [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/lib64/libpthread.so.0 [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/libverify.so [0]
      5193:     /usr/java/jdk1.7.0_09/jre/lib/amd64/libzip.so: error: symbol lookup error: undefined symbol: Java_sun_jdbc_odbc_JdbcOdbc_allocEnv (fatal)
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/libnio.so [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/libjava.so [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/libnet.so [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/lib64/libpthread.so.0 [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/lib64/libdl.so.2 [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/lib64/libc.so.6 [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/server/libjvm.so [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/libverify.so [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/lib64/libm.so.6 [0]
      5193:     /usr/java/jdk1.7.0_09/jre/lib/amd64/libnio.so: error: symbol lookup error: undefined symbol: Java_sun_jdbc_odbc_JdbcOdbc_allocEnv (fatal)
      5193:     symbol=Java_sun_jdbc_odbc_JdbcOdbc_allocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/libJdbcOdbc.so [0]
      5193:     binding file /usr/java/jdk1.7.0_09/jre/lib/amd64/libJdbcOdbc.so [0] to /usr/java/jdk1.7.0_09/jre/lib/amd64/libJdbcOdbc.so [0]: normal symbol `Java_sun_jdbc_odbc_JdbcOdbc_allocEnv'
      5193:     symbol=SQLAllocEnv;  lookup in file=java [0]
      5193:     symbol=SQLAllocEnv;  lookup in file=/lib64/libpthread.so.0 [0]
      5193:     symbol=SQLAllocEnv;  lookup in file=/usr/java/jdk1.7.0_09/bin/../jre/lib/amd64/jli/libjli.so [0]
      5193:     symbol=SQLAllocEnv;  lookup in file=/lib64/libdl.so.2 [0]
      5193:     symbol=SQLAllocEnv;  lookup in file=/lib64/libc.so.6 [0]
      5193:     symbol=SQLAllocEnv;  lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
      5193:     symbol=SQLAllocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/server/libjvm.so [0]
      5193:     symbol=SQLAllocEnv;  lookup in file=/lib64/libm.so.6 [0]
      5193:     symbol=SQLAllocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/libJdbcOdbc.so [0]
      5193:     symbol=SQLAllocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/libjava.so [0]
      5193:     symbol=SQLAllocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/server/libjvm.so [0]
      5193:     symbol=SQLAllocEnv;  lookup in file=/lib64/libc.so.6 [0]
      5193:     symbol=SQLAllocEnv;  lookup in file=/usr/java/jdk1.7.0_09/jre/lib/amd64/libverify.so [0]
      5193:     symbol=SQLAllocEnv;  lookup in file=/lib64/libdl.so.2 [0]
      5193:     symbol=SQLAllocEnv;  lookup in file=/lib64/libm.so.6 [0]
      5193:     symbol=SQLAllocEnv;  lookup in file=/lib64/libpthread.so.0 [0]
      5193:     symbol=SQLAllocEnv;  lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
      5193:     /usr/java/jdk1.7.0_09/jre/lib/amd64/libJdbcOdbc.so: error: symbol lookup error: undefined symbol: SQLAllocEnv (fatal)

我安装unixODBC显然这些函数的实现驻留在libodbc.so(符号链接到libodbc.so.2.0.0),

nm -a /usr/local/lib/libodbc.so | grep "SQLAllocEnv"
0000000000006f30 T SQLAllocEnv
0000000000000000 a SQLAllocEnv.c

我的LD_LIBRARY_PATH中有/ usr / local / lib(我确实导出了)。我还在/etc/ld.so.conf.d中放置了一个新的配置文件并运行了ldconfig。但由于某种原因,这个功能(可能是其他功能)不会加载。

另外

ldd /usr/java/latest/jre/lib/amd64/libJdbcOdbc.so
        linux-vdso.so.1 =>  (0x00007fff09728000)
        libjava.so => /usr/java/latest/jre/lib/amd64/libjava.so (0x00007fb8d03ab000)
        libjvm.so => not found
        libc.so.6 => /lib64/libc.so.6 (0x00007fb8d000d000)
        libjvm.so => not found
        libverify.so => /usr/java/latest/jre/lib/amd64/libverify.so (0x00007fb8cfdfe000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007fb8cfbfa000)
        /lib64/ld-linux-x86-64.so.2 (0x000000368b000000)
        libjvm.so => not found

任何人都可以给我任何建议,我该如何解决这个问题。据我所知,当链接器动态解析调用时,它将使用LD_LIBRARY_PATH来搜索elf文件。它是否正确?是否有某种索引可以用于查找具有所需功能的共享库?我知道创建的ld.so.cache,但必须有一些索引,即 SQLAllocEnv - > x.so,libodbc.so等。什么使链接器在这些特定文件中查找symobols?

由于

1 个答案:

答案 0 :(得分:0)

此错误仅表示在默认位置找不到很少的库文件。你可以像导出LD_LIBRARY_PATH = / usr / java / latest / jre / lib / amd64那样导出它。它应该解决问题。