Search code examples
javasqlitejakarta-eeejbdatabase-connection

ERROR [stderr] (EJB default - 8) java.lang.ClassNotFoundException: org.sqlite.JDBC


I'm trying to make a connection with sqlite database in j2ee project, but i keep getting this error "ERROR [stderr] (EJB default -8)java.lang.ClassNotFoundException: org.sqlite.JDBC". Knowing that I test the method in java program and that's work fine. I have one connection class in ejb project(session bean)there is the code here.

public Connection getConnection(){
    Connection connection= null;


    try {
        Class.forName("org.sqlite.JDBC");
        String dataFolder = System.getProperty("user.home") + "\\AppData\\Local";
        String b = System.getProperty("user.home") ;



        String file = b + "\\Desktop\\file";
        connection = DriverManager.getConnection("jdbc:sqlite:"+ file );
       System.out.println("Connection completed.");
    } catch (Exception e) {
        e.printStackTrace();
    }

    return connection;
 }

then I test it with junit test in java project but everytime i get the same error :java.Lang.ClassNotFoundException: org.sqlite.JDBC PS: I have incuded sqlite.jar like this (right click on the project->configure build path-> library-> add external jar) but always facing the same error


Solution

  • I have fixed the problem:

    1. Added SQLite jar file in this path:

      D:\jboss-as-7.1.1.Final\modules\javax\activation\api\main

    2. In JBoss Server Runtime > Deployments > Manage Deployments added SQLite jar file an then enable it.