grails - Convert org.apache.tomcat.jdbc.pool.DataSource to org.apache.commons.dbcp.BasicDataSource -


upgrading grails 2.2.1 2.4.3 else has upgraded fine, having issue tomcat upgrade 7.0.54 getting error of

error initializing application: error creating bean name 'datasourcembean': unsatisfied dependency expressed through constructor argument index 0 of type [org.apache.commons.dbcp.basicdatasource]: not convert constructor argument value of type [org.apache.tomcat.jdbc.pool.datasource] required type [org.apache.commons.dbcp.basicdatasource]: failed convert value of type 'org.apache.tomcat.jdbc.pool.datasource' required type 'org.apache.commons.dbcp.basicdatasource'; nested exception java.lang.illegalstateexception: cannot convert value of type [org.apache.tomcat.jdbc.pool.datasource] required type [org.apache.commons.dbcp.basicdatasource]: no matching editors or conversion strategy found org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'datasourcembean': unsatisfied dependency expressed through constructor argument index 0 of type [org.apache.commons.dbcp.basicdatasource]: not convert constructor argument value of type [org.apache.tomcat.jdbc.pool.datasource] required type [org.apache.commons.dbcp.basicdatasource]: failed convert value of type 'org.apache.tomcat.jdbc.pool.datasource' required type 'org.apache.commons.dbcp.basicdatasource'; nested exception java.lang.illegalstateexception: cannot convert value of type [org.apache.tomcat.jdbc.pool.datasource] required type [org.apache.commons.dbcp.basicdatasource]: no matching editors or conversion strategy found      @ org.springframework.beans.factory.support.constructorresolver.createargumentarray(constructorresolver.java:722)     @ org.springframework.beans.factory.support.constructorresolver.autowireconstructor(constructorresolver.java:185)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.autowireconstructor(abstractautowirecapablebeanfactory.java:1114)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbeaninstance(abstractautowirecapablebeanfactory.java:1017)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:504)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:475)     @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:302)     @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:228)     @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:298)     @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:193)     @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:703)     @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:760)     @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:482)     @ org.codehaus.groovy.grails.commons.spring.defaultruntimespringconfiguration.getapplicationcontext(defaultruntimespringconfiguration.java:156)     @ org.codehaus.groovy.grails.commons.spring.grailsruntimeconfigurator.initializecontext(grailsruntimeconfigurator.java:188)     @ org.codehaus.groovy.grails.commons.spring.grailsruntimeconfigurator.configure(grailsruntimeconfigurator.java:168)     @ org.codehaus.groovy.grails.commons.spring.grailsruntimeconfigurator.configure(grailsruntimeconfigurator.java:127)     @ org.codehaus.groovy.grails.web.context.grailsconfigutils.configurewebapplicationcontext(grailsconfigutils.java:126)     @ org.codehaus.groovy.grails.web.context.grailscontextloaderlistener.initwebapplicationcontext(grailscontextloaderlistener.java:109)     @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:106)     @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4973)     @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5467)     @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1559)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1549)     @ java.util.concurrent.futuretask.run(futuretask.java:262)      @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615)     @ java.lang.thread.run(thread.java:745) 

the area getting error in has been around while

datasourcembean(com.item.management.datasourcembean, ref('datasourceunproxied')) 

the class is:

class datasourcembean {         private basicdatasource datasource           public datasourcembean(basicdatasource datasource) {                this.datasource = datasource      } 

when change datasource to specific type :

private org.apache.tomcat.jdbc.pool.datasource datasource 

everything compiles , tests run fine.
asking when did change? there alternative basicdatasource should using instead?

i found article but, not sure if applies java.lang.classcastexception: org.apache.tomcat.dbcp.dbcp.basicdatasource cannot cast org.apache.tomcat.jdbc.pool.datasource

unless need basicdatasource (and can't see why would), don't change more specific class, change interface, javax.sql.datasource. if need particular implementation class, can define own datasource bean registering org.apache.commons.dbcp.basicdatasource in resources.groovy , setting whatever properties needed, e.g.

import org.apache.commons.dbcp.basicdatasource  beans = {    datasourceunproxied(basicdatasource) {       driverclassname = 'foo'       username = 'bar'       password = 'secret'       url = 'the_url'       ...    }    ... } 

you can bean registered grails or plugin long use same bean name.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -