title: How to solve the jboss + oracle problem: "the network adapter could not stablish the connection"?
body: <p>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.</p>
  
  <p>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).</p>
  
  <p>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:</p>
  
  <pre><code>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) [:]
  </code></pre>
  
  <p>The data source configuration file <strong>oracle-ds.xml</strong> is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;datasources&gt;
      &lt;local-tx-datasource&gt;
          &lt;jndi-name&gt;oracleDS&lt;/jndi-name&gt;
          &lt;connection-url&gt;jdbc:oracle:thin:@192.168.10.20:1521:ODB&lt;/connection-url&gt;
          &lt;driver-class&gt;oracle.jdbc.driver.OracleDriver&lt;/driver-class&gt;
          &lt;user-name&gt;myusername&lt;/user-name&gt;
          &lt;password&gt;mypassword&lt;/password&gt;
          &lt;valid-connection-checker-class-name&gt;org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker&lt;/valid-connection-checker-class-name&gt;
          &lt;metadata&gt;
              &lt;type-mapping&gt;Oracle9i&lt;/type-mapping&gt;
          &lt;/metadata&gt;
        &lt;min-pool-size&gt;0&lt;/min-pool-size&gt;
        &lt;max-pool-size&gt;20&lt;/max-pool-size&gt;
        &lt;idle-timeout-minutes&gt;0&lt;/idle-timeout-minutes&gt;
        &lt;/local-tx-datasource&gt;
  &lt;/datasources&gt;
  </code></pre>
  
  <p>The relevant parts of the EJB are:</p>
  
  <pre><code>@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();
  </code></pre>
  
  <p>I have already played with different values for the @Resource tag, different Oracle JDBC drivers (currently we are using <strong>ojdbc14.jar</strong> and <strong>orai18n.jar</strong>. The connection works either directly or through OpenEJB.</p>
  
  <p>Does anybody have a hint of what might be wrong? 
  Thanks</p>