java - Spring Tool Suite - ClassNotFoundException: oracle.jdbc.driver.OracleDriver -


i keep fighting spring. i'm trying connect app local oracle database, error:

classnotfoundexception: oracle.jdbc.driver.oracledriver 

i figured out problem missing .jar, , tried include it, keep getting same error.

i install oracle jdbc jar in maven repository, checked loads correctly in project, classes, etc., still not working.

i tried add jar in build path, , warning saying won't include it.

i tried copy&paste jar workspace, server, java path... , nothing.

the thing couldn't copy web-inf/lib folder (as answers recommended), because folder doesn't exists in project. sts didn't created (i assume that's because folder structure spring mvc webapplication not same usual webapplication one).

any ideas?

-- update --

my pom.xml requested:

<?xml version="1.0" encoding="utf-8"?> <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>ar.com</groupid> <artifactid>violenciaesmentir</artifactid> <name>blog</name> <packaging>war</packaging> <version>1.0.0-build-snapshot</version> <properties>   <java-version>1.8</java-version>   <org.springframework-version>4.1.6.release</org.springframework-version>   <org.aspectj-version>1.6.10</org.aspectj-version>   <org.slf4j-version>1.6.6</org.slf4j-version> </properties> <dependencies>   <!-- spring -->   <dependency>     <groupid>org.springframework</groupid>     <artifactid>spring-context</artifactid>     <version>${org.springframework-version}</version>     <exclusions>       <!-- exclude commons logging in favor of slf4j -->       <exclusion>         <groupid>commons-logging</groupid>         <artifactid>commons-logging</artifactid>       </exclusion>     </exclusions>   </dependency>   <dependency>     <groupid>org.springframework</groupid>     <artifactid>spring-webmvc</artifactid>     <version>${org.springframework-version}</version>   </dependency>    <!-- aspectj -->   <dependency>     <groupid>org.aspectj</groupid>     <artifactid>aspectjrt</artifactid>     <version>${org.aspectj-version}</version>   </dependency>     <!-- logging -->   <dependency>     <groupid>org.slf4j</groupid>     <artifactid>slf4j-api</artifactid>     <version>${org.slf4j-version}</version>   </dependency>   <dependency>     <groupid>org.slf4j</groupid>     <artifactid>jcl-over-slf4j</artifactid>     <version>${org.slf4j-version}</version>     <scope>runtime</scope>   </dependency>   <dependency>     <groupid>org.slf4j</groupid>     <artifactid>slf4j-log4j12</artifactid>     <version>${org.slf4j-version}</version>     <scope>runtime</scope>   </dependency>   <dependency>     <groupid>log4j</groupid>     <artifactid>log4j</artifactid>     <version>1.2.15</version>     <exclusions>       <exclusion>         <groupid>javax.mail</groupid>         <artifactid>mail</artifactid>       </exclusion>       <exclusion>         <groupid>javax.jms</groupid>         <artifactid>jms</artifactid>       </exclusion>       <exclusion>         <groupid>com.sun.jdmk</groupid>         <artifactid>jmxtools</artifactid>       </exclusion>       <exclusion>         <groupid>com.sun.jmx</groupid>         <artifactid>jmxri</artifactid>       </exclusion>     </exclusions>     <scope>runtime</scope>   </dependency>    <!-- @inject -->   <dependency>     <groupid>javax.inject</groupid>     <artifactid>javax.inject</artifactid>     <version>1</version>   </dependency>    <!-- servlet -->   <dependency>     <groupid>javax.servlet</groupid>     <artifactid>servlet-api</artifactid>     <version>2.5</version>     <scope>provided</scope>   </dependency>   <dependency>     <groupid>javax.servlet.jsp</groupid>     <artifactid>jsp-api</artifactid>     <version>2.1</version>     <scope>provided</scope>   </dependency>   <dependency>     <groupid>javax.servlet</groupid>     <artifactid>jstl</artifactid>     <version>1.2</version>   </dependency>    <!-- test -->   <dependency>     <groupid>junit</groupid>     <artifactid>junit</artifactid>     <version>4.7</version>     <scope>test</scope>   </dependency> </dependencies> <build>   <plugins>     <plugin>       <artifactid>maven-eclipse-plugin</artifactid>       <version>2.9</version>       <configuration>         <additionalprojectnatures>           <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>         </additionalprojectnatures>         <additionalbuildcommands>           <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>           </additionalbuildcommands>           <downloadsources>true</downloadsources>           <downloadjavadocs>true</downloadjavadocs>         </configuration>       </plugin>       <plugin>         <groupid>org.apache.maven.plugins</groupid>         <artifactid>maven-compiler-plugin</artifactid>         <version>2.5.1</version>         <configuration>           <source>1.8</source>           <target>1.8</target>           <compilerargument>-xlint:all</compilerargument>           <showwarnings>true</showwarnings>           <showdeprecation>true</showdeprecation>         </configuration>       </plugin>       <plugin>         <groupid>org.codehaus.mojo</groupid>         <artifactid>exec-maven-plugin</artifactid>         <version>1.2.1</version>         <configuration>           <mainclass>org.test.int1.main</mainclass>         </configuration>       </plugin>     </plugins>   </build> </project> 

there few different options want do.

  1. install own repository such nexus, artifactory , deploy jars in repository, after can declare them dependency in pom file.

  2. put jar file somewhere on machine (preferably ${base.dir}/lib folder), use system scope while declaring maven dependency , provide systempath jar. first, copy ojdbc.jar file ${base.dir}/lib folder.

then in pom.xml declare dependency below;

<dependency>     <groupid>com.oracle</groupid>     <artifactid>ojdbc14</artifactid>     <version>10.2.0</version>     <scope>system</scope>     <systempath>${basedir}/lib/ojdbc14.jar</systempath> </dependency> 

use maven dependency plugin to include dependencies system scope;

<build> <plugins>     <plugin>         <groupid>org.apache.maven.plugins</groupid>         <artifactid>maven-dependency-plugin</artifactid>         <version>2.8</version>         <executions>             <execution>                 <id>copy-dependencies</id>                 <phase>compile</phase>                 <goals>                     <goal>copy-dependencies</goal>                 </goals>                 <configuration>                     <outputdirectory>${project.build.directory}/${project.build.finalname}/web-inf/lib</outputdirectory>                     <includescope>system</includescope>                 </configuration>             </execution>         </executions>     </plugin> </plugins> </build> 
  1. you can use maven install:install command install artifact in local repository , declare normal dependency in pom.xml file.

for example run following;

mvn install:install-file -dfile=ojdbc14.jar -dgroupid=com.oracle -dartifactid=ojdbc14 -dversion=10.2.0 -dpackaging=jar 

and declare dependecy in pom.xml;

<dependency>     <groupid>com.oracle</groupid>     <artifactid>ojdbc14</artifactid>     <version>10.2.0</version> </dependency> 

note: option 1 useful if group of developers , need few third party libs. way won't have keep installing jar in local repo , provide more control on project dependency management. option 2 , 3 means project compile/build machine , have configured , different machines every time installing/copying jar in ${base.dir} or local repository.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -