pshemek
pshemek

Reputation: 1419

java - Class [org.apache.derby.jdbc.ClientDriver] not found

Trying to connect to derby data base, and I get a below mentioned error:

Jan 17, 2014 2:05:36 PM org.hibernate.validator.internal.util.Version <clinit>
INFO: HV000001: Hibernate Validator 5.0.0.Final
[EL Info]: 2014-01-17 14:05:36.35--ServerSession(989603483)--EclipseLink, version: Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5
[EL Severe]: ejb: 2014-01-17 14:05:36.36--ServerSession(989603483)--Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error.  Class [org.apache.derby.jdbc.ClientDriver] not found.
Exception in thread "main" javax.persistence.PersistenceException: Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error.  Class [org.apache.derby.jdbc.ClientDriver] not found.
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:766)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:182)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getDatabaseSession(EntityManagerFactoryImpl.java:527)
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:140)
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
    at com.mycompany.managingpersistanceobjects.App.main(App.java:20)
Caused by: Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error.  Class [org.apache.derby.jdbc.ClientDriver] not found.
    at org.eclipse.persistence.exceptions.DatabaseException.configurationErrorClassNotFound(DatabaseException.java:89)
    at org.eclipse.persistence.sessions.DefaultConnector.loadDriverClass(DefaultConnector.java:267)
    at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:85)
    at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.setOrDetectDatasource(DatabaseSessionImpl.java:204)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:741)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:239)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:685)
    ... 8 more
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.590s
Finished at: Fri Jan 17 14:05:36 CET 2014
Final Memory: 5M/121M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project ManagingPersistanceObjects: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Here is a main class:

public class App {

    public static void main(String[] args) {
        Customer customer = new Customer("Anthony", "Balla", "[email protected]");
        Address address = new Address("Rirherdon RD", "London", "8QE", "UK");
        customer.setAddress(address);

        EntityManagerFactory emf = Persistence.createEntityManagerFactory("chapter06PU");
        EntityManager em = emf.createEntityManager();
        EntityTransaction et = em.getTransaction();

        et.begin();
        em.persist(customer);
        et.commit();
        em.close();
        emf.close();

    }
}

Here is Persistence Unit:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="chapter06PU" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <properties>
      <property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/chapter06PU;create=true"/>
      <property name="javax.persistence.jdbc.password" value="app"/>
      <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
      <property name="javax.persistence.jdbc.user" value="app"/>
      <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
    </properties>
  </persistence-unit>
</persistence>

The data base running:

Fri Jan 17 10:37:31 CET 2014 : Security manager installed using the Basic server
 security policy.
Fri Jan 17 10:37:31 CET 2014 : Apache Derby Network Server - 10.10.1.1 - (145826
8) started and ready to accept connections on port 1527

and I believe I have the dependency to the client in POM:

<dependency>
    <groupId>org.apache.derby</groupId>
    <artifactId>derby</artifactId>
    <version>10.10.1.1</version>
    <type>jar</type>
</dependency>

Can you advice?

Upvotes: 1

Views: 4695

Answers (4)

You need a derby driver installer in the application server for this to work. It is not enough to include it in your application itself.

The simplest way to do so for the Java distributions at the time the question was asked, as I believe Derby is included in the JDK, is to tell JBoss to use the JDK instead of the default JRE.

Upvotes: 3

Meziane
Meziane

Reputation: 56

You need just to use derbyclient instead of derby as artifactId:

<dependency>
    <groupId>org.apache.derby</groupId>
    <artifactId>derbyclient</artifactId>
    <version>10.10.1.1</version>
    <type>jar</type> 
</dependency>

......

Upvotes: 4

Mario Kutlev
Mario Kutlev

Reputation: 5096

You must copy derbyclient.jar in your Tomcat server's lib folder.

See this answer.

Upvotes: 0

petur
petur

Reputation: 1386

Says the JDBC driver is not found. Have you included it in your library?

Upvotes: 1

Related Questions