I'm using Eclipse EE Kepler and I'm trying to run derby in my program. I added to my build path derby.jar
and derbyclient.jar
and still I'm getting the following error:
java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver
.
Can someone help me with solving this problem?

- 10,998
- 11
- 48
- 78

- 91
- 2
- 2
- 8
-
2clean and build the project. – Pradeep Kr Kaushal Jan 21 '14 at 15:29
-
Done already and nothing happend. Any other ideas? – Krystian Szczygielski Jan 21 '14 at 15:31
-
Check with Ctrl+Shift+T and type the class name which is missing. – Pradeep Kr Kaushal Jan 21 '14 at 15:34
-
2This class no longer exists in the very latest release of Derby -- 10.15.x -- as the driver is automatically loaded based on the JDBC URL. Fun for all of the code that expects a driver class to be specified -- try not specifying one at all if you're using a version of derby with a derbyshared.jar. – NerdDad Apr 04 '19 at 16:25
-
Wow, @NerdDad, googling for this error drew a blank until I came across your comment - using an earlier version made my `Class [org.apache.derby.jdbc.EmbeddedDriver] not found.` error go away! – Dave Griffiths Aug 24 '20 at 10:50
4 Answers
I stuck with the same problem 'java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver'. In my case, scope attribute is set to test
<!-- https://mvnrepository.com/artifact/org.apache.derby/derby -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.13.1.1</version>
<scope>test</scope>
</dependency>
You need to remove the scope element from the dependency and update the dependency like below.
<!-- https://mvnrepository.com/artifact/org.apache.derby/derby -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.13.1.1</version>
</dependency>
You may refer this post, to get complete working example.

- 3,658
- 1
- 36
- 57
You should not add these jars to the JRE directory, nor the server's lib directory. The real solution is to bundle the jars into your war file. You should consider using a build tool such as Ant or Maven. Here's how to accomplish this using Maven:
- Install Maven (for windows, following this tutorial: http://www.mkyong.com/maven/how-to-install-maven-in-windows/ )
- Create a pom.xml at the root of your project.
- Add your dependencies to the pom (see http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html for more details)
- Add the shade plugin to your pom (see http://maven.apache.org/plugins/maven-shade-plugin/examples/includes-excludes.html for more details)
- Run "mvn package" on the project
Here is a sample pom.xml (this is probably not a functional example):
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.10.2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

- 4,806
- 5
- 32
- 42
By adding jar to the build path in eclipse project, you are making derby driver available at compile time. But it is important that you should also make it available when container is running it. So copy your jar file in server lib directory.

- 2,210
- 18
- 26
-
I already solved my problem - o copied derby.jar and derbyclient.jar to my Program Files(x86)/Java/jre... and it started to work. Thanks for help. – Krystian Szczygielski Jan 21 '14 at 15:41
-
2Adding to the jre directory is not a right solution. Its not a good practice to put any jars in the JRE directory ... You need to include it in your classpath or package the required jar into the project. – Neeraj Krishna Jan 21 '14 at 16:05
I had same problem (Windows 7, JDK 7, Eclipse Kepler) and just added C:\Program Files\Java\jdk1.7.0_25\db\lib
to the Project properties -> Run/Debug settings -> Classpath -> User entries -> Add External JARs and it works.

- 7,238
- 14
- 83
- 113