tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Marcum <bmar...@BCScomputers.com>
Subject Re: Seeking the right solution to java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Date Mon, 20 Jul 2009 23:03:23 GMT
Thank you all for your help.

Caldarale, Charles R wrote:
>>From: Bob Marcum [mailto:bmarcum@BCScomputers.com]
>>Subject: Re: Seeking the right solution to
>>java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
>>
>>I did a "find" scan of my system, looking for other copies of
>>both hibernate3.jar and mysql-connector-java-3.1.10-bin.jar to
>>confirm there are no other copies which could be in classpath.
> 
> 
> Your find might have been a bit too specific, since you mustn't have any jars for any
version of Hibernate or MySQL in your webapp's classloader branch, other than in WEB-INF/lib.
> 
 I did a find on mysql-connector-java-*.jar.  Should have caught everything.

> 
>>There is a link to the mysql driver jar in hibernate-3.0's
>>own lib directory.
> 
> 
> What do you mean by "hibernate-3.0's own lib directory"?  Is this a link somehow inside
the Hibernate jar?  Are the Hibernate classes somewhere else besides the jar in WEB-INF/lib?
> 

No.  I am afraid I have confused the issue.  There is a lib directory in the hibernate distribution.
 One is instructed by the dist readme to copy your jdbc driver into that lib ... but it is
only used when running the tests to confiem hibernate works okay.  I have explored this a
little more since my last post.

> 
>>When I re-run the application, I am right back where I was. I
>>get "java.lang.ClassNotFoundException: com.mysql.jdbc.Driver".
> 
> 
> What's in the <Context> element for your webapp?  Since you're using C3P0 pooling,
you should not have a <Resource> element inside the <Context>, otherwise Tomcat
will also attempt to do pooling for the driver.
> 
I am using a context.xml which has the following in it:

> <Context debug="5">
  <Resource
    name="jdbc/CSRapp"
    description="DB Connection"
    type="javax.sql.DataSource"
    scope="shareable"

    driverClassName="com.mysql.jdbc.Driver"
    factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
    url="jdbc:mysql://localhost:3306/CSRapp"
    username="CSRapp"
    password="CSRapp"
    auth="Container"

    validationQuery="select 1"
    maxActive="10" 
    maxWait="5000"
    maxIdle="4" />
</Context>

This is as recommended by tomcat documentation, as I understand that documentation.

>>My webapp cannot see the mysql driver jar, although it clearly 
>>sees the hibernate jar.
> 
> 
> Post the complete stack trace for the CNFE.
> 

Here is the complete stack trace from catalina.log.  I have the debugger set to spit out a
lot of data:

serviceProviderRecord = [Ljava.lang.String;@13c6a22
16:38:33,723  INFO Environment:464 - Hibernate 3.0.5
16:38:33,734  INFO Environment:477 - hibernate.properties not found
16:38:33,741  INFO Environment:510 - using CGLIB reflection optimizer
16:38:33,753  INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
16:38:34,321  INFO Configuration:1110 - configuring from resource: /hibernate.cfg.xml
16:38:34,323  INFO Configuration:1081 - Configuration resource: /hibernate.cfg.xml
16:38:34,658  INFO Configuration:444 - Mapping resource: org/bcs/server/utils/ServiceProvider.hbm.xml
16:38:35,018  INFO HbmBinder:260 - Mapping class: org.bcs.server.utils.ServiceProvider ->
ServiceProvider
16:38:35,133  WARN HbmBinder:422 - Could not perform validation checks for component as the
class org.bcs.server.utils.ServiceProvider was not found
16:38:35,145  INFO Configuration:1222 - Configured SessionFactory: null
16:38:35,149  INFO Configuration:875 - processing extends queue
16:38:35,153  INFO Configuration:879 - processing collection mappings
16:38:35,155  INFO Configuration:888 - processing association property references
16:38:35,156  INFO Configuration:917 - processing foreign key constraints
16:38:36,141  INFO NamingHelper:26 - JNDI InitialContext properties:{}
16:38:36,147  INFO DatasourceConnectionProvider:51 - Using datasource: java:comp/env/jdbc/CSRapp
16:38:36,166  WARN SettingsFactory:103 - Could not obtain connection metadata
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
        at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:59)
        at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
        at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1004)
        at org.bcs.server.db.HibernateUtil.<clinit>(Unknown Source)
        at org.bcs.server.db.ModelFacade.findAllLikeThis(Unknown Source)
        at org.bcs.server.SelectionSearchServiceImpl.findAllLikeThis(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:527)
        at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:163)
        at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:85)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1130)
        ... 29 more
16:38:36,247  INFO Dialect:92 - Using dialect: org.hibernate.dialect.MySQLDialect
16:38:36,270  INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct
JDBC transactions)
16:38:36,284  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured
(in JTA environment, use of read-write or transactional second-level cache is not recommended)
16:38:36,293  INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
16:38:36,295  INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
16:38:36,300  INFO SettingsFactory:144 - Scrollable result sets: disabled
16:38:36,302  INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled
16:38:36,303  INFO SettingsFactory:160 - Connection release mode: null
16:38:36,309  INFO SettingsFactory:184 - Maximum outer join fetch depth: 2
16:38:36,311  INFO SettingsFactory:187 - Default batch fetch size: 1
16:38:36,312  INFO SettingsFactory:191 - Generate SQL with comments: disabled
16:38:36,314  INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
16:38:36,315  INFO SettingsFactory:334 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
16:38:36,331  INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
16:38:36,338  INFO SettingsFactory:203 - Query language substitutions: {}
16:38:36,342  INFO SettingsFactory:209 - Second-level cache: enabled
16:38:36,346  INFO SettingsFactory:213 - Query cache: disabled
16:38:36,354  INFO SettingsFactory:321 - Cache provider: org.hibernate.cache.EhCacheProvider
16:38:36,381  INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
16:38:36,394  INFO SettingsFactory:237 - Structured second-level cache entries: disabled
16:38:36,430  INFO SettingsFactory:261 - Statistics: disabled
16:38:36,432  INFO SettingsFactory:265 - Deleted entity synthetic identifier rollback: disabled
16:38:36,437  INFO SettingsFactory:279 - Default entity-mode: pojo
16:38:36,771  INFO SessionFactoryImpl:152 - building session factory
16:38:36,804  WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml
found in the classpath: jar:file:/usr/local/Apache.org/Tomcat/6.0.18/webapps/CSRapp/WEB-INF/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
16:38:37,660  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name
configured
16:38:37,662  INFO SessionFactoryImpl:379 - Checking 0 named queries
16:38:37,803 DEBUG ConnectionManager:296 - opening JDBC connection
16:38:37,820  WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: null
16:38:37,822 ERROR JDBCExceptionReporter:72 - Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
org.hibernate.exception.GenericJDBCException: Cannot open connection
        at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
        at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
        at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:301)
        at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:110)
        at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:137)
        at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:49)
        at org.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:24)
        at org.hibernate.jdbc.JDBCContext.beginTransaction(JDBCContext.java:271)
        at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1079)
        at org.bcs.server.db.ModelFacade.findAllLikeThis(Unknown Source)
        at org.bcs.server.SelectionSearchServiceImpl.findAllLikeThis(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:527)
        at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:163)
        at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:85)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
        at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:59)
        at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:298)
        ... 29 more
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1130)
        ... 32 more
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
16:39:27,188 DEBUG ConnectionManager:369 - running Session.finalize()



Here is the complete stack trace from localhost ... log:

Jul 20, 2009 4:38:37 PM org.apache.catalina.core.ApplicationContext log
SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.lang.String[][]
org.bcs.client.gui.SelectionSearchService.findAllLikeThis(java.lang.String[])' threw an unexpected
exception: org.hibernate.exception.GenericJDBCException: Cannot open connection
        at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:360)
        at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:546)
        at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:163)
        at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:85)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
        at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
        at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
        at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:301)
        at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:110)
        at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:137)
        at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:49)
        at org.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:24)
        at org.hibernate.jdbc.JDBCContext.beginTransaction(JDBCContext.java:271)
        at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1079)
        at org.bcs.server.db.ModelFacade.findAllLikeThis(Unknown Source)
        at org.bcs.server.SelectionSearchServiceImpl.findAllLikeThis(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:527)
        ... 16 more
Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
        at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:59)
        at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:298)
        ... 29 more
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1130)
        ... 32 more




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message