0
votes

I have added spring bean with Id-dataSource and added properties for Oracle DB configuration and Also added Generic Database Configuration which is referring to that bean.

 <spring:beans>
 <spring:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"   destroy-method="close" name="Bean">
    <spring:property name="url" value="${oracleAQ.url}"/> 
    <spring:property name="username" value="${oracleAQ.userName}"/> 
    <spring:property name="password" value="${oracleAQ.password}"/> 
    <spring:property name="initialSize" value="10"/> 
    <spring:property name="maxActive" value="50"/>
        <spring:property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> 
    </spring:bean>
  </spring:beans>



    <db:generic-config name="Generic_Database_Configuration" dataSource-ref="dataSource" doc:name="Generic Database Configuration"/>

Dependencies I have added for oracle db are ojdbc8, and commons-dbcp

  <dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
 <artifactId>ojdbc8</artifactId>
 <version>12.2.0.1</version>
</dependency>

But, while running this project I am seeing errors like,

org.mule.module.launcher.DeploymentInitException: NoSuchBeanDefinitionException: No bean named 'dataSource' is defined at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:212) ~[mule-module-launcher-3.8.4.jar:3.8.4] at org.mule.module.launcher.artifact.ArtifactWrapper$2.execute(ArtifactWrapper.java:63) ~[mule-module-launcher-3.8.4.jar:3.8.4] at org.mule.module.launcher.artifact.ArtifactWrapper.executeWithinArtifactClassLoader(ArtifactWrapper.java:136) ~[mule-module-launcher-3.8.4.jar:3.8.4] at org.mule.module.launcher.artifact.ArtifactWrapper.init(ArtifactWrapper.java:58) ~[mule-module-launcher-3.8.4.jar:3.8.4] at org.mule.module.launcher.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:25) ~[mule-module-launcher-3.8.4.jar:3.8.4] at org.mule.module.launcher.DefaultArchiveDeployer.redeploy(DefaultArchiveDeployer.java:463) ~[mule-module-launcher-3.8.4.jar:3.8.4] at org.mule.module.launcher.DeploymentDirectoryWatcher.redeployModifiedArtifacts(DeploymentDirectoryWatcher.java:562) ~[mule-module-launcher-3.8.4.jar:3.8.4] at org.mule.module.launcher.DeploymentDirectoryWatcher.redeployModifiedApplications(DeploymentDirectoryWatcher.java:539) ~[mule-module-launcher-3.8.4.jar:3.8.4] at org.mule.module.launcher.DeploymentDirectoryWatcher.run(DeploymentDirectoryWatcher.java:352) ~[mule-module-launcher-3.8.4.jar:3.8.4] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_181] at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) ~[?:1.8.0_181] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) ~[?:1.8.0_181] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) ~[?:1.8.0_181] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_181] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_181] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181] Caused by: org.mule.api.config.ConfigurationException: Error creating bean with name '_muleNotificationManager': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Generic_Database_Configuration': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource' is defined Please find attached screenshot NoSuchBeanDefinitionException

I am not able to find the solution for this. Can anyone please help me on resolving this..

1
Is there more log? Sometimes the error is related with not being able to instantiate the bean "dataSource" (for example if you don't have those properties values defined in a properties file....) - Álvaro Pérez Soria
Try with maven using shell. Sometimes, anypoint studio is misleading - JRichardsz
does changing the class work? <spring:bean id="Oracle_Connector_Data_Source" name="Oracle_Connector_Data_Source" class="oracle.jdbc.pool.OracleDataSource"> - utechtzs
If we change the class to "oracle.jdbc.pool.OracleDataSource" , field names like (username, password, url etc) are not available as we have in class "org.apache.commons.dbcp.BasicDataSource" - Zakira Nafeesa
Are you sure that oracleAQ.url, oracleAQ.userName, oracleAQ.password are defined and configured? - Álvaro Pérez Soria

1 Answers

0
votes

Can you try changing name to "dataSource" from "Bean". I think the two identifiers is causing the issue.