Loading

Error trying to load driver: oracle.jdbc.driver.OracleDriver

Date de publication: Mar 2, 2024
Résolution

SYMPTOM


Please note: This article applies to Mule 4.

You are experiencing the following issue on Mule 4 when you are try to deploy an application that has a DB connector using a 3rd Party Library. The example below is using the DB connector and the Oracle JDBC driver

ERROR 2018-09-20 12:31:87,235 [WrapperListener_start_runner] org.mule.runtime.core.retry.notifiers.ConnectNotifier: Failed to connect/reconnect: Testing connectivity for config 'Oracle_Database'.
Error trying to load driver: oracle.jdbc.driver.OracleDriver : Cannot load class 'oracle.jdbc.driver.OracleDriver': [
oracle.jdbc.driver.OracleDriver, 
Cannot load class 'oracle.jdbc.driver.OracleDriver': [
Class 'oracle.jdbc.driver.OracleDriver' has no package mapping for region 'domain/default/app/Untitled'., 
Cannot load class 'oracle.jdbc.driver.OracleDriver': [
oracle.jdbc.driver.OracleDriver, 
Class 'oracle.jdbc.driver.OracleDriver' not found in classloader for artifact 'container'.]]]
Type: class java.sql.SQLException


Within your pom.xml within Studio, you have added the the following entry.
 

<dependency>
	<groupId>com.oracle</groupId>
	<artifactId>ojdbc6</artifactId>
	<version>11.2.0.3</version>
</dependency>
 

Which works fine within Studio 7, but not when you deploy to a Mule Runtime.

CAUSE

The driver is required by more than one component therefore it is necessary to add this as a shared library within the pom.xml

SOLUTION 

The solution is to alter the configuration section of the pom.xml to include the following entry
 

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.mycompany</groupId>
    <artifactId>myapp</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>mule-application</packaging>

    <name>myapp</name>

    <properties>
        <... some properties />
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.mule.tools.maven</groupId>
                <artifactId>mule-maven-plugin</artifactId>
                <version>${mule.maven.plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <sharedLibraries>
                        <sharedLibrary>
                            <groupId>com.oracle</groupId>
                            <artifactId>ojdbc6</artifactId>
                        </sharedLibrary>
                    </sharedLibraries>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <... some other dependancies />
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
        </dependency>        
    </dependencies>

    <repositories>
        <repository>
            <... details/>
        <repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <... details/>
        </pluginRepository>
    </pluginRepositories>
</project>
Numéro d’article de la base de connaissances

001117951

 
Chargement
Salesforce Help | Article