'Mule, Spring, MyBatis - Could not get a databaseId from dataSource

I'm trying to build a simple mule REST service based on an Spring+MyBatis application which I've created earlier. The spring app worked just as it was supposed to (transactions were working properly) but after integrating the code into Mule REST component and running the app I get the following log with an error:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Initializing app 'test_rest'                             +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO  2014-05-19 09:51:58,651 [main] org.mule.lifecycle.AbstractLifecycleManager: Initialising RegistryBroker
INFO  2014-05-19 09:51:58,813 [main] org.mule.config.spring.MuleApplicationContext: Refreshing org.mule.config.spring.MuleApplicationContext@6b1de1c2: startup date [Mon May 19 09:51:58 CEST 2014]; root of context hierarchy
INFO  2014-05-19 09:52:00,762 [main] org.mule.config.spring.MuleApplicationContext: Bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
INFO  2014-05-19 09:52:00,766 [main] org.mule.config.spring.MuleApplicationContext: Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
INFO  2014-05-19 09:52:01,291 [main] org.springframework.jdbc.datasource.DriverManagerDataSource: Loaded JDBC driver: oracle.jdbc.OracleDriver
ERROR 2014-05-19 09:52:01,408 [main] org.apache.ibatis.executor.BaseExecutor: Could not get a databaseId from dataSource
java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@//192.168.200.10:1522/ORCL
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:173)
    at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:164)
    at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:153)
    at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:119)
    at org.apache.ibatis.mapping.VendorDatabaseIdProvider.getDatabaseProductName(VendorDatabaseIdProvider.java:76)
    at org.apache.ibatis.mapping.VendorDatabaseIdProvider.getDatabaseName(VendorDatabaseIdProvider.java:61)
    at org.apache.ibatis.mapping.VendorDatabaseIdProvider.getDatabaseId(VendorDatabaseIdProvider.java:49)
    at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:395)
    at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:295)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1391)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1132)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getTypeForFactoryBean(AbstractBeanFactory.java:1360)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:724)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:520)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:357)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:335)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:435)
    at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1188)
    at org.mule.config.spring.SpringRegistry.internalLookupByType(SpringRegistry.java:178)
    at org.mule.config.spring.SpringRegistry.lookupByType(SpringRegistry.java:171)
    at org.mule.registry.AbstractRegistryBroker.lookupByType(AbstractRegistryBroker.java:160)
    at org.mule.registry.MuleRegistryHelper.lookupByType(MuleRegistryHelper.java:709)
    at org.mule.config.bootstrap.SimpleRegistryBootstrap.registerTransformers(SimpleRegistryBootstrap.java:322)
    at org.mule.config.bootstrap.SimpleRegistryBootstrap.initialise(SimpleRegistryBootstrap.java:185)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1612)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1553)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.mule.config.spring.SpringRegistry.doInitialise(SpringRegistry.java:89)
    at org.mule.registry.AbstractRegistry.initialise(AbstractRegistry.java:109)
    at org.mule.config.spring.SpringXmlConfigurationBuilder.createSpringRegistry(SpringXmlConfigurationBuilder.java:119)
    at org.mule.config.spring.SpringXmlConfigurationBuilder.doConfigure(SpringXmlConfigurationBuilder.java:73)
    at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:46)
    at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
    at org.mule.config.builders.AutoConfigurationBuilder.autoConfigure(AutoConfigurationBuilder.java:101)
    at org.mule.config.builders.AutoConfigurationBuilder.doConfigure(AutoConfigurationBuilder.java:57)
    at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:46)
    at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
    at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:84)
    at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:207)
    at org.mule.module.launcher.application.ApplicationWrapper.init(ApplicationWrapper.java:64)
    at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:47)
    at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:127)

My spring config looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<beans ...>

    <context:annotation-config />
    <tx:annotation-driven />


    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="oracle.jdbc.OracleDriver" />
        <property name="url" value="jdbc:oracle:thin:@//database_ip:port/service" />
        <property name="username" value="" />
        <property name="password" value="" />
    </bean>


    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
    </bean>

    <bean id="mapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
        <property name="mapperInterface" value="com.example.mapper.Mapper" />
        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
    </bean>

    <bean id="service" class="com.example.service.Service" />

</beans>

My mule config xml:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.4.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/jersey http://www.mulesoft.org/schema/mule/jersey/current/mule-jersey.xsd">

    <spring:beans>
        <spring:import resource="classes/spring-config.xml" />
    </spring:beans>
    <flow name="test_restFlow1" doc:name="test_restFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" path="rest"/>
        <logger level="INFO" doc:name="Logger"/>
        <jersey:resources doc:name="REST">
            <component class="com.example.service.Service"/>
        </jersey:resources>
    </flow>

</mule>

The classes referenced in the xml files, Mapper:

package com.example.mapper;

import java.util.List;

import com.example.vo.Person;

public interface Mapper {
    public List<Person> selectAllPerson();
    public int insertPerson(Person person);
}

Service:

package com.example.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.example.mapper.Mapper;
import com.example.vo.Person;
import javax.ws.rs.*;

@Path("/person")
public class Service {

    @Autowired
    private Mapper mapper;

    @GET
    @Path("/select")
    @Produces("text/plain")
    public String selectAllPerson() {
        return mapper.selectAllPerson().toString();
    }

    public void insertPerson(Person person) {
        mapper.insertPerson(person);
    }
}

Person:

package com.example.vo;

public class Person {
    private int id;
    private String name;

    public int getId() {return id;};
    public void setId(int id) {this.id = id;}
    public String getName() {return name;};
    public void setName(String name) {this.name = name;}

    public String toString() {return "id: " + id + " name: " + name;}
}


Solution 1:[1]

No suitable driver found for jdbc:oracle:thin:@//192.168.200.10:1522/ORCL

Is the Oracle JDBC driver packaged with your application? This seems to mean it's not. Did you add it to the pom.xml?

Solution 2:[2]

Are you using AnyPointStudio/MuleStudio to run in mule server 3.5 ? Chances are that the driver jar is not present in the app server library as it fails to pick up the driver jar from application classpath. If it is local then you can try to add the jar to the following location: (Ur IDE Installation Folder)\plugins\org.mule.tooling.server.3.5.0.ee_3.5.0.201405141846\mule\lib\boot. It worked for me.

Solution 3:[3]

You should check the configuration like url username or password , Usually caused by this

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David Dossot
Solution 2
Solution 3 yw w