尝试使用 OCI 连接到 Oracle 时 JVM 崩溃
我设置了三台计算机,如下所示:
- CompA:运行 Oracle 服务器 10.2.0.3
- CompB:运行 Oracle 服务器 10.2.0.4 和我的客户端代码
- CompC:仅运行客户端代码
在 CompB 和 CompC 上的客户端代码上,连接到 Oracle DB使用 Thin 驱动程序可以完美运行。
通过 OCI 驱动程序从客户端代码连接到每个 Oracle DB
Connection conn = DriverManager.getConnection('jdbc:oracle:oci:username/pass@sid');
我正在尝试使用在 jboss 中运行的 Java 类内部 。 这在 CompB 上工作得很好,但会导致运行 Jboss 的 JVM 每次在 CompC 上进行核心转储。
CompC 可以使用 Sql*Plus 和 jboss 尝试引用的同一 tnsnames.ora 文件连接到两台 Oracle 服务器。
这是堆栈跟踪的一部分。 它似乎每次都是一致的。
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
有谁知道这里出了什么问题?
更新:为了澄清,上面使用的“客户端”是指我在 jboss 实例中运行的 java 代码。 应该在 jboss 启动时使用的 LD_LIBRARY_PATH 中找到的唯一 Oracle 库是 libocijdbc10.so libclntsh.so.10.1 和 libnnz10.so。 这三个库和 jboss 服务器本身都在源代码管理中,因此它们在 CompB 和 CompC 上是相同的版本。
CompB 可以使用 OCI 和 Thin 连接到 CompA 和 CompB。 CompC 无法使用 OCI 连接,但可以使用 Thin 连接到 CompA 和 CompB,因此这不应该是服务器版本问题。
CompB 和 CompC 都运行 32 位 Ubuntu 8.04,但与 CompB 的 3.25GB RAM 相比,CompC 的 CPU 稍慢,并且只有 1GB RAM。
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
On the client code on both CompB and CompC, connecting to either Oracle DB works flawlessly using the Thin driver.
I am trying to connect to each Oracle DB from the client code through the OCI driver using
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.
CompC can connect to both Oracle servers using Sql*Plus and the same tnsnames.ora file that jboss is trying to reference.
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.
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,我刚刚看完一集《豪斯医生》,所以让我们在这里尝试一下鉴别诊断。 您知道它可以与两台机器上的 Thin 驱动程序一起使用,但它在 JBoss 代码中已过期。 您没有肯定地说(“客户端”不是很明确),但看起来您在 CompB 和 CompC 上都有一个 JBoss 实例,并且当您的代码在 CompB 上的 JBoss 实例中运行时运行得很愉快,但核心转储来自 CompC。
从设置中,我推断当您在 CompB 上运行时,您正在与 CompB 上的 Oracle 实例通信。 您是否尝试过在 CompB 上运行代码但与 CompA 对话? 您是否尝试过在 CompC 上运行代码,但在 CompB 上与 Oracle 通信?
实际错误表明 dynlib 模块“libocijdbc10.so”中的本机代码中发生了错误,并且我们知道 CompA 和 CompB 上有不同版本的 Oracle 内容。 所以我的第一个怀疑是两台机器上的 libocijdbc10.so 版本不兼容。 我发现 CompA 和 CompB 上的 Oracle 版本不同。 我预测 CompB 上与 CompA 的 oracle 通信的代码将会失败,而 CompC 上与 CompB 通信的代码将会运行。
您想要检查 CompB 和 CompC 上 Oracle OCI 驱动程序软件的版本。
更新
好吧,你说:
所以,你已经缩小了范围。 三种连接方法(Thin、SQL*Plus 和 OCI)和三台服务器,唯一失败的是使用 CompC 的 OCI; 无法与 CompA 和 CompB 通信。
由此可见,问题是 CompC JBoss 上的配置问题。 Oracle 提供的驱动程序仍然失败; 由于在 CompB 上运行时相同的代码适用于 CompA 和 CompB,因此它必须是 CompC 问题,而不是代码中的问题。
因此,
来自 CompB 和 CompC 的库
并确认它们是相同的。
从 CompB 到 CompC 并进行测试。
配置控制。
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.
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?
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.
You want to check the versions of the Oracle OCI driver software on CompB and CompC.
Update
Okay, you say:
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.
It follows the problem is a configuration problem on CompC JBoss. It's still failing in the 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.
So
libraries from CompB and from CompC
and confirm they're the same.
from CompB onto CompC and test.
configuration control.
放弃本机 OCI 驱动程序 - 这是一个永无休止的头痛。
使用纯 java 驱动程序 - 它更稳定、更快并且使用更少的内存。
Just give up on the native OCI driver - it's a never-ending headache.
Use the pure java driver - it's more stable, faster and uses less memory.