尝试使用 OCI 连接到 Oracle 时 JVM 崩溃
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/679684/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JVM crashes when trying to connect to Oracle using OCI
提问by Ryan Ahearn
I have three machines set up as follows:
我有三台机器设置如下:
- CompA: Running Oracle server 10.2.0.3
- CompB: Running Oracle server 10.2.0.4 and my client code
- CompC: Running client code only
- CompA:运行 Oracle 服务器 10.2.0.3
- CompB:运行 Oracle 服务器 10.2.0.4 和我的客户端代码
- CompC:仅运行客户端代码
On the client code on both CompB and CompC, connecting to either Oracle DB works flawlessly using the Thin driver.
在 CompB 和 CompC 上的客户端代码上,使用瘦驱动程序连接到任一 Oracle DB 都可以完美运行。
I am trying to connect to each Oracle DB from the client code through the OCI driver using
我正在尝试使用 OCI 驱动程序从客户端代码连接到每个 Oracle DB
Connection conn = DriverManager.getConnection('jdbc:oracle:oci:username/pass@sid');
From inside of a Java class that is running in jboss. This works just fine on CompB, but causes the JVM running Jboss to core dump every time on CompC.
从在 jboss 中运行的 Java 类内部。这在 CompB 上工作得很好,但是每次在 CompC 上都会导致运行 Jboss 的 JVM 进行核心转储。
CompC can connect to both Oracle servers using Sql*Plus and the same tnsnames.ora file that jboss is trying to reference.
CompC 可以使用 Sql*Plus 和 jboss 试图引用的同一个 tnsnames.ora 文件连接到两个 Oracle 服务器。
Here is a portion of the stack trace. It appears to be consistent each and every time.
这是堆栈跟踪的一部分。它似乎每次都是一致的。
Stack: [0x30fcc000,0x3101d000), sp=0x3101a868, free space=314k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.so+0x2d02d6] C [libocijdbc10.so+0x585c] C [libocijdbc10.so+0x70a8] Java_oracle_jdbc_driver_T2CConnection_t2cCreateState+0x15c j oracle.jdbc.driver.T2CConnection.t2cCreateState([BI[BI[BI[BISI[S[B[B)I+0 j oracle.jdbc.driver.T2CConnection.logon()V+551 j oracle.jdbc.driver.PhysicalConnection.(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Properties;Loracle/jdbc/driver/OracleDriverExtension;)V+381 j oracle.jdbc.driver.T2CConnection.(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Properties;Loracle/jdbc/driver/OracleDriverExtension;)V+10 j oracle.jdbc.driver.T2CDriverExtension.getConnection(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;+67 j oracle.jdbc.driver.OracleDriver.connect(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;+831 j java.sql.DriverManager.getConnection(Ljava/lang/String;Ljava/util/Properties;Ljava/lang/ClassLoader;)Ljava/sql/Connection;+210 j java.sql.DriverManager.getConnection(Ljava/lang/String;)Ljava/sql/Connection;+15
Does anyone know what's going wrong here?
有谁知道这里出了什么问题?
UPDATE: For clarification, "client", as used above refers to my java code running in a jboss instance. The only Oracle libraries that should be found in the LD_LIBRARY_PATH that jboss is started with are libocijdbc10.so libclntsh.so.10.1 and libnnz10.so. These three libraries and the jboss server itself are in source control, so they are the same versions on both CompB and CompC.
更新:为了澄清起见,上面使用的“客户端”是指我在 jboss 实例中运行的 java 代码。唯一应该在 jboss 启动的 LD_LIBRARY_PATH 中找到的 Oracle 库是 libocijdbc10.so libclntsh.so.10.1 和 libnnz10.so。这三个库和 jboss 服务器本身都在源代码控制中,因此它们在 CompB 和 CompC 上是相同的版本。
CompB can connect, using OCI and thin, to both CompA and CompB. CompC cannot connect using OCI, but can connect using thin, to both CompA and CompB, so it shouldn't be a server version issue.
CompB 可以使用 OCI 和 Thin 连接到 CompA 和 CompB。CompC 无法使用 OCI 连接,但可以使用 Thin 连接到 CompA 和 CompB,因此应该不是服务器版本问题。
Both CompB and CompC are running 32-bit Ubuntu 8.04, though CompC has a slightly slower CPU and only 1GB of RAM, compared to 3.25GB RAM on CompB.
CompB 和 CompC 都运行 32 位 Ubuntu 8.04,尽管与 CompB 上的 3.25GB RAM 相比,CompC 的 CPU 速度稍慢且只有 1GB 的 RAM。
回答by Charlie Martin
Well, I just finished watching an episode of House, so let's try a differential diagnosis here. You know that it works with the Thin driver from both machines, but it's expiring in the JBoss code. You don't say for sure ("client" isn't very definite) but it would appear that you have a JBoss instance on CompB and on CompC, and your code runs happily when it runs in the JBoss instance on CompB but core dumps from CompC.
好吧,我刚刚看完了 House 的一集,所以让我们在这里尝试鉴别诊断。您知道它适用于两台机器的 Thin 驱动程序,但它在 JBoss 代码中已过期。您不确定(“客户端”不是很确定),但看起来您在 CompB 和 CompC 上有一个 JBoss 实例,并且您的代码在 CompB 上的 JBoss 实例中运行时运行愉快,但核心转储来自 CompC。
From the setup, I infer that when you run on CompB, you're talking to the Oracle instance on CompB. Have you tried running the code on CompB but talking to CompA? Have you tried running the code on CompC, but talking to the Oracle on CompB?
从设置中,我推断当您在 CompB 上运行时,您正在与 CompB 上的 Oracle 实例对话。您是否尝试过在 CompB 上运行代码但与 CompA 交谈?您是否尝试过在 CompC 上运行代码,但在 CompB 上与 Oracle 交谈?
The actual errors indicate a fault occurring in native code in a dynlib module "libocijdbc10.so" and we know that you have different versions of the Oracle stuff on CompA and CompB. So my first suspicion would be that you have incompatible versions of libocijdbc10.so on the two machines. I observe that you have a different version of Oracle on CompA and CompB. I predict that the code on CompB talking to CompA's oracle will fail, and that the code on CompC talking to CompB will run.
实际错误表明在 dynlib 模块“libocijdbc10.so”中的本机代码中发生了错误,我们知道您在 CompA 和 CompB 上有不同版本的 Oracle 内容。所以我的第一个怀疑是你在两台机器上有不兼容的 libocijdbc10.so 版本。我观察到您在 CompA 和 CompB 上有不同版本的 Oracle。我预测 CompB 上与 CompA 的预言机对话的代码将失败,而 CompC 上与 CompB 对话的代码将运行。
You want to check the versions of the Oracle OCI driver software on CompB and CompC.
您想检查 CompB 和 CompC 上的 Oracle OCI 驱动程序软件的版本。
Update
更新
Okay, you say:
好吧,你说:
CompB can connect, using OCI and thin, to both CompA and CompB. CompC cannot connect using OCI, but can connect using thin, to both CompA and CompB, so it shouldn't be a server version issue.
CompB 可以使用 OCI 和 Thin 连接到 CompA 和 CompB。CompC 无法使用 OCI 连接,但可以使用 Thin 连接到 CompA 和 CompB,因此应该不是服务器版本问题。
So, you have this narrowed down. Three connection methods (Thin, SQL*Plus, and OCI) and three servers, and the only one that fails is using OCI from CompC; that fails talking to both CompA and CompB.
所以,你已经缩小了范围。三种连接方式(Thin、SQL*Plus 和 OCI)和三台服务器,唯一失败的是使用 CompC 的 OCI;未能与 CompA 和 CompB 交谈。
It follows the problem is a configuration problem on CompC JBoss. It's still failing inthe Oracle-supplied driver; since the same code works against CompA and CompB when running on CompB, it has to be a CompC problem, not a problem in your code.
随之而来的问题是 CompC JBoss 上的配置问题。在Oracle 提供的驱动程序中它仍然失败;由于在 CompB 上运行时,相同的代码对 CompA 和 CompB 起作用,因此它必须是 CompC 问题,而不是您的代码中的问题。
So
所以
- run cmp(1)against the driver libraries from CompB and from CompC and confirm they're the same.
- when they're not, rcp the drivers from CompB onto CompC and test.
- figure out what went wrong with the configuration control.
- 对来自 CompB 和来自 CompC 的驱动程序库运行cmp(1)并确认它们是相同的。
- 如果不是,则将驱动程序从 CompB 接收到 CompC 并进行测试。
- 找出配置控制出了什么问题。
回答by Ryan Ahearn
Just give up on the native OCI driver - it's a never-ending headache.
放弃本机 OCI 驱动程序 - 这是一个永无止境的头痛。
Use the pure java driver - it's more stable, faster and uses less memory.
使用纯 Java 驱动程序 - 它更稳定、更快并且使用更少的内存。