Error starting T4CConnection for OracleConnection

Spring using JNDI lookup to get datasource like this:

   @Bean(name = "dataSource1", destroyMethod = StringUtils.EMPTY)
    public DataSource dataSource() {
        final JndiDataSourceLookup lookup = new JndiDataSourceLookup();
        lookup.setResourceRef(true);

        return lookup.getDataSource(this.environment.getProperty(Constants.DB_JNDI_NAME_ES));
    }

      

and get the data source connection like this:

@Autowired
@Qualifier("dataSource1")
private DataSource ds;



 Connection conn = null;
 conn = this.ds.getConnection();

      

But when I pass this connection to the StructDescriptor it throws a classCastException like this:

StructDescriptor desc1 = StructDescriptor.createDescriptor ("MSAF_DBA.AMOUNT_DUE_OBJ", Conn);

java.lang.ClassCastException: weblogic.jdbc.wrapper.PoolConnection_oracle_jdbc_driver_T4CConnection cannot be cast to oracle.jdbc.OracleConnection
    at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:101)
    at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:72)
    at com.ceiwc.es.policyholder.dao.PolicyHolderDaoImpl.getAmountDue(PolicyHolderDaoImpl.java:290)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)

      

I understand that it getConnection()

returns a T4CConnection

where required OracleConnection

. Tried a couple of ways to get OracleConnection

it but didn't seem to work. Any help would be appreciated.

+3


source to share


1 answer


I believe it has something to do with the content of your war / ear file. Do not package the Oracle driver in a .jar file.

In particular, if you have it ojdbc6.jar

in your war file (or equivalent) it will cause conflicts. It's good to use this jar for compilation, but you don't want it in your classpath as it is already in the default Weblogic classpath.



See these links for similar information: here and here

+3


source







All Articles