0

by now, I spent the whole day to solve this problem, with no success. I have a RESTful (jax-rs) server application, and I want it to receive data from a mysql-db. I need a driver for my DriverManager, and when I try to load it via

class.ForName("org.gjt.mm.mysql.Driver");

I only receive a ClassNotFoundException. Obvisously, I have to add my mysql-connector.jar to my project. But I tried so many different ways, I keep getting the same error. I read that I had to put the .jar into the WEB-INF/lib folder, but this did not work for me. I tried adding it as a dependency in the maven pom.xml, with no success.

What am I doing so wrong?

PKlumpp
  • 4,913
  • 8
  • 36
  • 64
  • 1
    Do you see this in your classpath and in your WEB-INF/lib folder? – ucsunil Mar 26 '14 at 18:35
  • I could manually put it into my WEB-INF/lib folder again (removed it to test something else), but I am not sure how to add it to my classpath properly :-/ – PKlumpp Mar 26 '14 at 18:43
  • 1
    This link gives information on how to add them to the build path in eclipse - https://wiki.eclipse.org/FAQ_How_do_I_add_an_extra_library_to_my_project's_classpath%3F – ucsunil Mar 26 '14 at 18:46
  • Can you see if that works? Adding it to the WEB-INF/lib is for applications to see it on the server. You need it in the buildpath for the app on your local machine to see and run it. – ucsunil Mar 26 '14 at 18:47
  • Well, i put it into the WEB-INF/lib folder, and updated my classpath. The problem persists. I have no idea what is going on. And I am trying to run it on the server btw ;) – PKlumpp Mar 26 '14 at 18:55
  • You still need it on your build path so that the program can compile and run. Do you see the jar in your java build path through Eclipse? It has to be missing. If it is in your build path, can you expand that jar and see this class present in exactly the same package as you have mentioned. It has to be this. – ucsunil Mar 26 '14 at 19:00
  • It is in the "Referenced Libraries"-folder. And the path to my Driver.class is correct. There might be another problem: When i upload my server-program to the server, i can't find the "referenced libraries"-folder anywhere in the server-folders. – PKlumpp Mar 26 '14 at 19:05
  • You should see this under normal libraries. Can you see if this is what you have done? http://stackoverflow.com/questions/3280353/how-to-import-a-jar-in-eclipse – ucsunil Mar 26 '14 at 19:10
  • yes, this is what i have done. and it is usual afaik that you see it in referenced libraries. – PKlumpp Mar 26 '14 at 19:15

0 Answers0