2 Replies Latest reply on Apr 22, 2002 10:32 AM by jweis

    JBOSS 3.0 and Tomcat 4.0.2 JDBC ClassCastException

    jweis

      I am new to JBOSS and have followed the examples in the JBOSS 3.0 html docs for setting up JDBC connection pooling with ORACLE. I have never succeeded in casting the retrieved DataSource to the javax.sql.DataSource interface. The below code snippet throws a class cast exception:

      // Get a reference to the datasource
      DataSource ds = (DataSource)jndiContext.lookup("java:/OracleDS");

      The cast exception is: java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.JDBCDataSource

      So I had to explicitly cast to the org.jboss.resource.adapter.jdbc.JDBCDataSource and things seem to work.

      The odd thing is that the org.jboss.resource.adapter.jdbc.JDBCDataSource claims to implement javax.sql.DataSource. Why does this not work? Has anyone actually tried to cast to a javax.sql.DataSource and had this work?

      I am using jboss-3.0.0beta and jakarta-tomcat-4.0.2 and I am using the following in my service.xml file to setup my JDBC connection:




      ConnectionURL=jdbc:oracle:thin:@MyMachine:1521:MyORCL
      DriverClass=oracle.jdbc.driver.OracleDriver

      OracleDS
      java:/TransactionManager
      <depends optional-attribute-name="ResourceAdapterName">jboss.jca:service=RARDeployment,name=Minerva JDBC LocalTransaction ResourceAdapter
      <depends optional-attribute-name="ConnectionManagerFactoryLoaderName">jboss.jca:service=ConnectionManagerFactoryLoader,name=MinervaSharedLocalCMFactory
      #
      #Wed Aug 15 16:17:29 EDT 2001
      BlockingTimeoutMillis=50000
      IdleTimeoutMinutes=30
      MaxSize=10
      CleanupIntervalMinutes=10
      MinSize=0
      MaxIdleTimeoutPercent=1.0


      org.jboss.resource.security.ManyToOnePrincipalMapping

      userName=jw
      password=jw