Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLException: No suitableDriver found

This is one of the most topics, but no other on stackoverflow fits.

My enviroment is a Tomcat 7 with a JNDI-DataSource defined in context.xml. When i start my Tomcat the following exception is thrown

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.apache.derby.jdbc.ClientDataSource' for connect URL 'jdbc:derby://localhost:1527/app;create=true'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:141)
at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)
at org.hibernate.tool.hbm2ddl.DatabaseExporter.<init>(DatabaseExporter.java:52)
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:367)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:304)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:293)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:498)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1743)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at com.opensolutions.openflow.persistence.DefaultEntityManagerStore.<init>(DefaultEntityManagerStore.java:20)
at com.opensolutions.openflow.servlet.ApplicationWebserviceServlet.initApplication(ApplicationWebserviceServlet.java:38)
at com.opensolutions.openflow.servlet.ApplicationWebserviceServlet.loadBus(ApplicationWebserviceServlet.java:27)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.init(CXFNonSpringServlet.java:71)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5033)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5317)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)

Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:289)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
... 37 more

Any solutions? I dont know. I tried so much, but nothing works.

like image 943
George Krause Avatar asked Dec 06 '25 08:12

George Krause


1 Answers

This line in the stack trace is the key to solving the problem:

Caused by: java.sql.SQLException: No suitable driver

Since the exception is thrown at org.apache.tomcat... it seems that you haven't placed your database driver in tomcat's lib directory (i.e. you are missing dependencies). The folder stores external dependencies that are needed by your applications and is located in apache-tomcat-version/lib/. You need to supply the driver to both your web application and tomcat server.

Also, have a look at these related quetions:

  1. JDBC/MSQL: No suitable driver found
  2. Cause of No suitable driver found
  3. java.sql.SQLException: No suitable driver found


EDIT

The problem is perhaps that the webapp doesn't have access to the library, Try adding the library in tomcat-home-folder/common/lib. I tried this and tomcat7 did not have a common folder, so I would instead placed the library into webapp/WEB-INF/lib

like image 162
Lyuben Todorov Avatar answered Dec 10 '25 01:12

Lyuben Todorov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!