oracle jboss+oracle问题:“网卡无法建立连接”怎么解决?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3494150/
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
How to solve the jboss + oracle problem: "the network adapter could not stablish the connection"?
提问by Luis Soeiro
I'm using Oracle 10.2.0.4 server and we are testing Java Application Servers in order to chose the most appropriate for our needs. So far we managed to get OpenEJB and GlassFish working, but not JBoss.
我使用的是 Oracle 10.2.0.4 服务器,我们正在测试 Java 应用服务器,以便选择最适合我们需求的服务器。到目前为止,我们设法让 OpenEJB 和 GlassFish 工作,但不是 JBoss。
We have a simple fat Java client connecting to a simple EJB 3.0 (stateless session bean), which in turn, tries to perform a simple SQL query using an oracle data source. This same setup has already worked with Apache's OpenEJB and Sun's Glashfish. However, we couldn't make it work with either Jboss 5.1.0.GA or Jboss-6.0.0.20100721-M4 (the latest milestone).
我们有一个简单的胖 Java 客户端连接到一个简单的 EJB 3.0(无状态会话 bean),它反过来尝试使用 oracle 数据源执行简单的 SQL 查询。Apache 的 OpenEJB 和 Sun 的 Glashfish 已经采用了相同的设置。但是,我们无法使其与 Jboss 5.1.0.GA 或 Jboss-6.0.0.20100721-M4(最新里程碑)一起使用。
Jboss deploys the EJB without errors and the EJB can indeed be reached by the client. However, when the EJB tries to get a connection from the Oracle data source it fails with:
Jboss 部署 EJB 没有错误,并且客户端确实可以访问 EJB。但是,当 EJB 尝试从 Oracle 数据源获取连接时,它会失败并显示:
11:04:34,837 INFO [STDOUT] oracleDS=org.jboss.resource.adapter.jdbc.WrapperDataSource@63d587bf
11:04:45,110 WARN [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Throwable while attempting to get a new connection: null: org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: I/O Exception: The Network Adapter could not establish the connection)
at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:225) [:6.0.0.20100721-M4]
at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:195) [:6.0.0.20100721-M4]
at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:643) [:6.0.0.20100721-M4]
at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:267) [:6.0.0.20100721-M4]
at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:747) [:6.0.0.20100721-M4]
at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:403) [:6.0.0.20100721-M4]
at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:413) [:6.0.0.20100721-M4]
at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:496) [:6.0.0.20100721-M4]
at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941) [:6.0.0.20100721-M4]
at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89) [:6.0.0.20100721-M4]
at test.ejb.Business.getResults(Business.java:184) [:]
The data source configuration file oracle-ds.xmlis:
数据源配置文件oracle-ds.xml为:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>oracleDS</jndi-name>
<connection-url>jdbc:oracle:thin:@192.168.10.20:1521:ODB</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>myusername</user-name>
<password>mypassword</password>
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
<min-pool-size>0</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>0</idle-timeout-minutes>
</local-tx-datasource>
</datasources>
The relevant parts of the EJB are:
EJB 的相关部分是:
@Stateless
public class Business implements BusinessRemote {
@Resource(name = "oracleDS",mappedName="java:oracleDS")
private DataSource oracleDS;
public String validateEJB(String value) {
return value + "ok";
}
public String[] getResults() {
String[] result = null;
Connection con = null;
Statement st = null;
ResultSet rs = null;
try {
//Fails here
con = oracleDS.getConnection();
I have already played with different values for the @Resource tag, different Oracle JDBC drivers (currently we are using ojdbc14.jarand orai18n.jar. The connection works either directly or through OpenEJB.
我已经为 @Resource 标记使用了不同的值,不同的 Oracle JDBC 驱动程序(目前我们使用ojdbc14.jar和orai18n.jar。连接直接或通过 OpenEJB 工作。
Does anybody have a hint of what might be wrong? Thanks
有没有人暗示可能有什么问题?谢谢
回答by Luis Soeiro
The problem lies on an invisible versionning conflict of the drivers. You have to make absolutely sure that both oracle JARs come from the same version and also that there are no other Oracle JARs in the CLASSPATH.
问题在于驱动程序的不可见版本冲突。您必须绝对确保两个 oracle JAR 来自同一版本,并且 CLASSPATH 中没有其他 Oracle JAR。