tomcat 6.0.24 Exception: Could not load com.mysql.jdbc.SQLError

前端 未结 8 731
甜味超标
甜味超标 2021-02-04 18:20

My tomcat 5 server running on centos frequently (several times / day) produces the following error:

Apr 7, 2011 11:02:30 PM org.apache.catalina.loader.WebappClas         


        
相关标签:
8条回答
  • 2021-02-04 18:55

    Newer versions of Tomcat require that you put JDBC driver JARs in the Tomcat /lib directory, not your WEB-INF. And there should only be one version in that directory - the version you want to use - and no others.

    Since you're using Tomcat 5, I'd recommend putting the JAR in your server/lib directory.

    I don't know if this is the root cause of your problem, but it's worth a try.

    0 讨论(0)
  • 2021-02-04 19:01

    Use only one version of jar file in WEB-INF/lib directory. Better use the latest version of mysql-connector-java 5.1.26.

    0 讨论(0)
  • 2021-02-04 19:05

    You could check the order of directories in the classpath. I once had two versions of a jar file: one in the working directory and another in the Java Extensions directory. The order of the classpath was: check eclipse extensions directory first, then working directory second. Once it found a version of the jar in the extensions directory, it didn't keep looking for the one I was specifying in the working directory. Order matters in the classpath.

    0 讨论(0)
  • 2021-02-04 19:09

    I think you have to use connection pooling mechanism for idle connections. or else check this link for connection pooling 'http://www.mkyong.com/hibernate/how-to-configure-the-c3p0-connection-pool-in-hibernate/'

    0 讨论(0)
  • 2021-02-04 19:10

    Apart from using only one version of jar (which the other users have suggested), please check the following as well:

    1. Make sure that when you are done with the database connection, close the connection with close() call.
    2. Errors like this might occur when you open number of connections and do not explicitly close them.
    3. In these situations, many a times, the database actually closes the idle connections but the object representing that connection on application side is still not closed.
    4. What happens is, these open connection objects are lurking and when the the finalizer runs (evident from the stack trace) and tries to close the connection, you get IllegalStateException as this connection object is not associated with any database connections.
    0 讨论(0)
  • 2021-02-04 19:18

    The error is not that the class can't be found. It's not being allowed to load because the web application has been stopped. I suspect this might be happening after the web application is restarted, where it's down for a short period of time. Then some finalize() method in the code is probably trying to do some cleanup too late. Whether or not that's in your code or the MySQL driver I can't say. You definitely should only have one version of a jar in a directory at a time. You might want to upgrade it to the latest (5.1.15 right now) in case something has been fixed that might be affecting you.

    0 讨论(0)
提交回复
热议问题