GeoTools
  1. GeoTools
  2. GEOT-4106

Could not obtain native oracle connection

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.7.4
    • Fix Version/s: None
    • Component/s: jdbc-oracle plugin
    • Labels:
      None
    • Environment:
      OS Windows 7 x64, Oracle 11.2.0.2.0, jdk1.6.0_27, apache-tomcat-6.0.35

      Description

      I'm using GeoTools 2.7.4, a oracle 11g DB, ojdbc14.jar, and a simple java code on a Tomcat 6 like this:

      Map map = new HashMap();
      map.put( "dbtype", "oracle");
      map.put( "jndiReferenceName", "java:comp/env/jdbc/GisDS");
      
      OracleNGJNDIDataStoreFactory factory = new OracleNGJNDIDataStoreFactory();
      log.info("Can process? "+ factory.canProcess(map));
      store = factory.createDataStore(map);
      
      SimpleFeatureSource featureSource = store.getFeatureSource(viewName);
      log.info(featureSource.getFeatures().getBounds().toString());
      

      And my context.xml:

      <Resource name="jdbc/GisDS" auth="Container" type="javax.sql.DataSource" 
          driverClassName="oracle.jdbc.driver.OracleDriver"
          accessToUnderlyingConnectionAllowed="true" 
          username="***" password="***"
          url="***"
          maxActive="25" maxIdle="8" maxWait="10000" 
          removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true" 
          poolPreparedStatements="true" maxOpenPreparedStatements="100"
          validationQuery="SELECT SYSDATE FROM DUAL"/>
      

      And I always get the "Could not obtain native oracle connection" error:

      java.lang.RuntimeException: java.io.IOException: Error occured calculating bounds
              at org.geotools.jdbc.JDBCFeatureSource.getBoundsInternal(JDBCFeatureSource.java:485)
              at org.geotools.jdbc.JDBCFeatureStore.getBoundsInternal(JDBCFeatureStore.java:179)
              at org.geotools.data.store.ContentFeatureSource.getBounds(ContentFeatureSource.java:370)
              at org.geotools.data.store.ContentFeatureCollection.getBounds(ContentFeatureCollection.java:274)
              at ***.GisServlet.doGet(GisServlet.java:82)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
              at java.lang.Thread.run(Thread.java:662)
      Caused by: java.io.IOException: Error occured calculating bounds
              at org.geotools.jdbc.JDBCDataStore.getBounds(JDBCDataStore.java:1137)
              at org.geotools.jdbc.JDBCFeatureSource.getBoundsInternal(JDBCFeatureSource.java:478)
              ... 19 more
      Caused by: java.sql.SQLException: Could not obtain native oracle connection for class org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper
              at org.geotools.data.oracle.OracleDialect.unwrapConnection(OracleDialect.java:490)
              at org.geotools.data.oracle.OracleDialect.readGeometry(OracleDialect.java:434)
              at org.geotools.data.oracle.OracleDialect.readGeometry(OracleDialect.java:424)
              at org.geotools.data.oracle.OracleDialect.decodeGeometryEnvelope(OracleDialect.java:371)
              at org.geotools.jdbc.JDBCDataStore.getBounds(JDBCDataStore.java:1123)
              ... 20 more
      

      I've tried to connect to a 10g DB, I've tried using the ojdbc6, and I always end with the same result.

      The strange is, the featureSource.getFeatures().size() works.

        Activity

        Hide
        Jan De Moerloose added a comment -
        I made another patch for the gt-oracle-jdbc component (GEOT-4356). The current geotools Unwrapper API can't delegate to java.sql.Wrapper as it requires you to pass the native connection class. To my disappointment, tomcat dbcp does not implement JDBC4, though, so this fix will not work with tomcat dbcp.
        Show
        Jan De Moerloose added a comment - I made another patch for the gt-oracle-jdbc component ( GEOT-4356 ). The current geotools Unwrapper API can't delegate to java.sql.Wrapper as it requires you to pass the native connection class. To my disappointment, tomcat dbcp does not implement JDBC4, though, so this fix will not work with tomcat dbcp.
        Hide
        Miles Jordan added a comment -
        Just for info - I've been getting this from my JNDI connection with geoserver since upgrading to 2.3.4 and can't seem to find a way around it. I can add the data store just fine but any geometry operation seems to cause the same exception.
        Show
        Miles Jordan added a comment - Just for info - I've been getting this from my JNDI connection with geoserver since upgrading to 2.3.4 and can't seem to find a way around it. I can add the data store just fine but any geometry operation seems to cause the same exception.
        Hide
        Andrea Aime added a comment -
        GeoServer wise, just tested with Tomcat 6.0.26 and GeoServer 2.4.x, the Spring unwrapper does it job. GeoTools wise, it's a matter of registering in SPI an unwrapper that works against the chosen connection pool, or use a pool that supports JDBC4 Unwrapper interface, out of the box we only provide support for DBCP
        Show
        Andrea Aime added a comment - GeoServer wise, just tested with Tomcat 6.0.26 and GeoServer 2.4.x, the Spring unwrapper does it job. GeoTools wise, it's a matter of registering in SPI an unwrapper that works against the chosen connection pool, or use a pool that supports JDBC4 Unwrapper interface, out of the box we only provide support for DBCP
        Hide
        Andrea Aime added a comment -
        Btw, support for JDBC 4 Wrapper has been added to the 11.x series only at the moment. Made a few checks, Tomcat JDBC pool does not support JDBC 4 in Tomcat 6, but that can be unwrapped by the Spring unwrappers, whilst Tomcat 7 completely fails to wrap the PreparedStatements, and our code does ps.getConnection(), getting the native oracle connection directly, so there is no need for un-wrappers there. It's not clear why this is happening, but in case it worked as expected, Tomcat 7 pool is able to support JDBC 4 Wrapper.
        Show
        Andrea Aime added a comment - Btw, support for JDBC 4 Wrapper has been added to the 11.x series only at the moment. Made a few checks, Tomcat JDBC pool does not support JDBC 4 in Tomcat 6, but that can be unwrapped by the Spring unwrappers, whilst Tomcat 7 completely fails to wrap the PreparedStatements, and our code does ps.getConnection(), getting the native oracle connection directly, so there is no need for un-wrappers there. It's not clear why this is happening, but in case it worked as expected, Tomcat 7 pool is able to support JDBC 4 Wrapper.
        Hide
        Andrea Aime added a comment - - edited
        For the record, recently we stumbled into this issue twice, in both cases it was due to the JDBC driver library being put both in the contained shared libs and in GeoServer, causing a classloading clash that resulted in the unwrapping failing. Removing the JDBC driver from GeoServer solves the issue.
        Show
        Andrea Aime added a comment - - edited For the record, recently we stumbled into this issue twice, in both cases it was due to the JDBC driver library being put both in the contained shared libs and in GeoServer, causing a classloading clash that resulted in the unwrapping failing. Removing the JDBC driver from GeoServer solves the issue.

          People

          • Assignee:
            Andrea Aime
            Reporter:
            Jose Antonio
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: