ClassNotFoundException for oracle driver when connecting to external database in jira plugin

I am currently developing a plugin to query a external oracle database. This is a standalone database and is not responsible for any core jira functionalities. The following are the steps I took to establish the connection:

  1. Download the ojdbc8.jar from oracle manually

  2. Execute the mvn install command to use the jar as a maven dependency

  3. Included the jar as a dependency:

    ```
        <dependency>
            <groupId>com.oracle</groupId>
             <artifactId>ojdbc8</artifactId>
             <version>12.2.0</version>
            <scope>provided</scope>
        </dependency>
    

4) called atlas-mvn eclipse:eclipse. atlas-mvn clean package, atlas-run in order to set up local instance and get all dependencies

5) This is my connection code: 


   public static Connection getERPOracleConnection() {
	try {
		Class.forName("oracle.jdbc.driver.OracleDriver");
		
	} catch (ClassNotFoundException e) {
		System.out.println("Oracle Driver missing ");
		e.printStackTrace();
		return null;
	}
	
	System.out.println("Oracle Driver Found. Establishing database connection...");
	Connection connection = null;
	try {
		connection = DriverManager.getConnection("jdbc:oracle:thin:@172.22.22.22:1521:dbname", "username", "password");
		
	} catch (SQLException e) {
		e.printStackTrace();
	}
	
	if(connection != null) {
		System.out.println("Oracle Connection Established!");
	}else {
		System.out.println("Connection Error");
	}
	
	return connection;
}

I was able to access some of the oracle related objects such as OracleTypes.cursor, so I am assuming that I pulled in all the dependencies correctly. But whenever I try to establish a JDBC connection with my external oracle database, I get the classNotFound exception.

<img src="//discourse-cloud-file-uploads.s3.dualstack.us-west-2.amazonaws.com/atlassiandeveloper/original/3X/d/e/def3bcf3bee15a97363a04109007aab741bbb0c7.png" width="690" height="336">

**Note**: The really weird  thing is this issue is somewhat intermittent. Sometimes when I do a mvn clean and atlas-run from scratch I was able to establish a connection. Most of the times I get the classNotFound Exception. 

Am I pulling in the dependencies wrong? Any suggestions?

Hi .

did you find a solution?

thanks

Hi @antoniojose.figueire,

I couldn’t get to the real reason for what caused the problem, but I was able to fix it by doing a clean build.

hi again @simonhuang92
It is possible to send me your pom.xml, just to see if is anything that may missing at mine?