1

I am trying to run Springboot application with Oracle DB. After executing

java -jar SpringBootHibernate-0.0.1-SNAPSHOT.jar

Getting below error of Unable to create initial connections of pool.

    2020-09-26 13:35:24 INFO  com.programmer.gate.Application - Starting Application v0.0.1-SNAPSHOT on lax13 with PID 1356 (/home/cavisson/spring-boot-jpa-hibernate-master/target/SpringBootHibernate-0.0.1-SNAPSHOT.jar started by root in /home/cavisson/spring-boot-jpa-hibernate-master/target)
2020-09-26 13:35:24 INFO  com.programmer.gate.Application - No active profile set, falling back to default profiles: default
2020-09-26 13:35:24 INFO  o.s.c.a.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@443b7951: startup date [Sat Sep 26 13:35:24 IST 2020]; root of context hierarchy
2020-09-26 13:35:25 WARN  o.a.tomcat.jdbc.pool.ConnectionPool - initialSize is larger than maxActive, setting initialSize to: 1
2020-09-26 13:35:25 WARN  o.a.tomcat.jdbc.pool.ConnectionPool - minIdle is larger than maxActive, setting minIdle to: 1
2020-09-26 13:35:25 WARN  o.a.tomcat.jdbc.pool.ConnectionPool - maxIdle is larger than maxActive, setting maxIdle to: 1
2020-09-26 13:35:25 ERROR o.a.tomcat.jdbc.pool.ConnectionPool - Unable to create initial connections of pool.
java.sql.SQLException: Unable to load class: oracle.jdbc.OracleDriver from ClassLoader:org.springframework.boot.loader.LaunchedURLClassLoader@19469ea2;ClassLoader:org.springframework.boot.loader.LaunchedURLClassLoader@19469ea2

Can someone help me the reason behind this error | I have crossed check that oracle connection is placed fine.

Here is my application properties -

# create n drop tables, loads import.sql
spring.jpa.hibernate.ddl-auto=create-drop

# Oracle settings
spring.datasource.url=jdbc:oracle:thin:@HostIP:1521:orcl
spring.datasource.username=SYS
spring.datasource.password=ABC@123
spring.datasource.driver.class=oracle.jdbc.driver.OracleDriver

# logging
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n
logging.level.org.hibernate.SQL=debug

spring.datasource.dbcp2.max-total=1
spring.datasource.tomcat.max-active=1

Entry in POM.xml

<dependency>
 <groupId>com.oracle</groupId>
 <artifactId>ojdbc7</artifactId>
 <version>12.1.0</version>
 </dependency>
  • Hi there, sharing the configurations you are using in your project would be very helpful. – Jorge Campos Sep 26 '20 at 08:12
  • And by the way there is almost an exact copy of your question here already the only difference is it is using MySql, maybe you have the same problem, take a look: https://stackoverflow.com/q/22155837/460557 – Jorge Campos Sep 26 '20 at 08:13
  • Does this answer your question? [SEVERE: Unable to create initial connections of pool - tomcat 7 with context.xml file](https://stackoverflow.com/questions/22155837/severe-unable-to-create-initial-connections-of-pool-tomcat-7-with-context-xml) – Jorge Campos Sep 26 '20 at 08:15

1 Answers1

3

From the logs you shared it seems like you are missing Oracle Driver in your pom.xml

Go to your pom.xml, scroll to the <dependencies> section and add the following dependency

<!-- https://mvnrepository.com/artifact/com.oracle.jdbc/ojdbc8 -->
<dependency>
    <groupId>com.oracle.jdbc</groupId>
    <artifactId>ojdbc8</artifactId>
    <version>12.2.0.1</version>
</dependency>

Then do a maven clean install to create a new jar and also make sure that you don't just copy paste the oracle dependency provided here but rather check if it is the one corresponding to your oracle version.

Do edit your question and add details of your pom.xml as well

Syed Anas
  • 1,459
  • 3
  • 19
  • 38
  • I am using ` com.oracle ojdbc6 11.2.0.3 system ${project.basedir}/src/main/webapp/WEB-INF/lib/oracle-ojdbc6-11.2.0.3.jar ` – Saurabh Gupta Sep 26 '20 at 08:26
  • Remove the `systemPath` and `scope` and then try – Syed Anas Sep 26 '20 at 08:29
  • I have done few changes, like `` `com.oracle` `ojdbc7` `12.1.0` `` I can see one jar inside .m2/repository/com/oracle/ojdbc7/12.1.0 But i am getting below Error Failed to execute goal on project SpringBootHibernate: Could not resolve dependencies for project com.programmer.gate:SpringBootHibernate:jar:0.0.1-SNAPSHOT: Failure to find com.oracle:ojdbc7:jar:12.1.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, – Saurabh Gupta Sep 26 '20 at 08:34
  • 1
    Understood, you need to update indices in your maven project, are you using intellij? I've faced this issue when the jar is there on m2 and its not on the project lib all you have to do is update maven indices and re install the project so it will bring the jar file in your lib folder – Syed Anas Sep 26 '20 at 10:56
  • @SaurabhGupta glad to help – Syed Anas Sep 28 '20 at 11:08