0

Spring MVC app has Oracle and Hibernate properties in a file like this (persistence-oracle.properties):

# jdbc.X
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=[Database URL]
jdbc.user=[Username]
jdbc.pass=[Password]

# hibernate.X
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
hibernate.show_sql=true
#hibernate.hbm2ddl.auto=create-drop

And while the tests show that the app can connect to and query the database and get data back, when I try to package it with maven, I get this error:

Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

The reason the properties are in this properties file and not hibernate.cfg.xml is because configuration is done via Spring Java Configuration similar to step 3 here

Why can't Maven find the driver while Spring can?

Edit1: Oracle dependency

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc6</artifactId>
    <version>11.2.0.3</version>
</dependency>
roark
  • 792
  • 1
  • 12
  • 29
  • Show us your dependency for oracle's driver and post your source folder configuration – Sotirios Delimanolis Oct 03 '13 at 17:56
  • It's very likely you have the scope set to **test** on that dependency – Bart Oct 03 '13 at 17:57
  • I didn't even have an Oracle dependency in Maven. When I add it as in the Edit, Eclipse shows this error though, "Missing artifact com.oracle:ojdbc6:jar:11.2.0.3" – roark Oct 03 '13 at 18:26
  • So the way it was explained to me is that I only need the oracle driver jar at compile time because the application server will have its own. So, I can add a compile to the oracle dependency so that Maven can build and so that there won't be conflicts between 2 jars at runtime (1 from Maven and 1 from app server) – roark Oct 03 '13 at 20:28

2 Answers2

1

Do you have to mention the oracle driver in the build path? if so, I think it could be the license issue see here Find Oracle JDBC driver in Maven repository

Community
  • 1
  • 1
Zeus
  • 6,386
  • 6
  • 54
  • 89
0

The ojdbc6 dependency what you are looking in the mvnrepo is not exact. One should add the collection tag for ojdbc6 verison dependency to get the jars dumped into your path.

Kumar
  • 1