2 Replies Latest reply on May 18, 2009 6:56 AM by Jeff Zhang

    Howto use custom jdbc driver with OracleXADatasource?

    Trey Ethridge Newbie

      I have a custom jdbc driver that is generic. We wrap the oracle jdbc driver so that we can add security as the sql passes through the driver. Now we need to use a XA datasource since we have multiple datasources.

      I'm trying to configure the datasource file so that it will use the oracle xa datasource and then have the oracle xa datasource use our custom jdbc driver. I've tried a lot of combinations. I tried setting the driver-class and connection-url to the values that have been working when we used a no-tx-datasource. If I remove the xa-datasource-property for URL or set it to the url that our custom jdbc driver expects, then I get an exception that looks like:

      2009-05-13 17:30:11,035 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: Invalid Oracle URL specified: OracleDataSource.makeURL)
       at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:155)
       at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:619)
       at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:264)
       at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:613)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:347)
       at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:330)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:402)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:849)
       at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
       at org.apache.jsp.Test_jsp._jspService(Test_jsp.java:90)
       at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
       at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
       at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
       at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
       at java.lang.Thread.run(Thread.java:619)
      Caused by: java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
       at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
       at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
       at oracle.jdbc.pool.OracleDataSource.makeURL(OracleDataSource.java:1353)
       at oracle.jdbc.pool.OracleDataSource.getURL(OracleDataSource.java:1064)
       at oracle.jdbc.xa.client.OracleXADataSource.getPooledConnection(OracleXADataSource.java:188)
       at oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:143)
       at oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:129)
       at oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:90)
       at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:137)
       ... 33 more



      If I set the xa-datasource-property for URL to the normal oracle jdbc thin client string, then I don't receive any errors. The problem is that it doesn't use my custom driver either.

      How can I configure the datasource configuration file to be a xa-datasource, but use our custom jdbc driver? Our driver has a custom url format that it expects to see. In the acceptsURL method it will return false if it doesn't see that format.