3

I got this exception:

java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver

I use jtds-1.2.2. I tried add jar or add external jar. I also do:

    String driver = "net.sourceforge.jtds.jdbc.Driver";

    try {
        Class.forName(driver);
    } catch (ClassNotFoundException e) { 
        // TODO Auto-generated catch block
        e.printStackTrace();
    }  

I did the same in java project and everything works good. But doing this in jsf project I get this exception. Why ?

1 Answer 1

3

The libraries used by a web application at runtime are all the jars placed in the WEB-INF/lib directory of the deployed webapp. Adding the library in the classpath used to compile the webapp doesn't make it automatically available at runtime.

If you're using Eclipse, just drop the jar in WebContent/WEB-INF/lib, and it will be automatically added to the build path (i.e. the classpath used to compile the app), and also be part of the deployed webapp, and thus be available at runtime.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.