1 Reply Latest reply on May 30, 2006 6:28 AM by o k

    ClassNotFoundException

    o k Newbie

      Hi!
      I need a help!
      I catch this exception when I try to reach my servlet. Here is the java code
      causing the problem:
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      I imported "mysql-connector-java-3.1.12-bin-g.jar" in my java project and I also placed it in this directory : /home/omezzine/DevTools/jboss-4.0.2/server/Omez/lib.

      Here is the console output:


      18:24:19,578 INFO [TomcatDeployer] deploy, ctxPath=/tp3, warUrl=file:/home/omezzine/DevTools/jboss-4.0.2/server/Omez/tmp/deploy/tmp17488tp3.war/
      18:24:26,003 INFO [STDOUT] java.lang.ClassNotFoundException: No ClassLoaders found for: com.mysql.jdbc.Driver
      18:24:26,004 INFO [STDOUT] at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:198)
      18:24:26,004 INFO [STDOUT] at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:475)
      18:24:26,004 INFO [STDOUT] at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:377)
      18:24:26,004 INFO [STDOUT] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
      18:24:26,004 INFO [STDOUT] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
      18:24:26,005 INFO [STDOUT] at java.lang.Class.forName0(Native Method)
      18:24:26,005 INFO [STDOUT] at java.lang.Class.forName(Class.java:164)
      18:24:26,005 INFO [STDOUT] at com.ebusiness.ebanque.application.StartServlet.getAllUsers(StartServlet.java:44)
      18:24:26,005 INFO [STDOUT] at com.ebusiness.ebanque.application.StartServlet.doGet(StartServlet.java:90)
      18:24:26,005 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
      18:24:26,005 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      18:24:26,005 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      18:24:26,005 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      18:24:26,005 INFO [STDOUT] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
      18:24:26,006 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      18:24:26,006 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      18:24:26,006 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      18:24:26,006 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      18:24:26,006 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      18:24:26,006 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
      18:24:26,006 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      18:24:26,006 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      18:24:26,006 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      18:24:26,007 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      18:24:26,007 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      18:24:26,007 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      18:24:26,007 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      18:24:26,007 INFO [STDOUT] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      18:24:26,007 INFO [STDOUT] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      18:24:26,007 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)


      Thanx!

        • 1. Re: ClassNotFoundException
          o k Newbie

          It's me again. I forgot to tell that I am using JBoss, Eclipse, MySQLConnector J and a MySQL database.

          I found the source of my error. I defined a classpath in my .bashrc to the driver's path and it's wrong. I just commented it and now it works.

          Conclusion: just add your driver (.jar) under your WEB-INF/lib directory and export it in the properties of your java project as an internal .jar.