3

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.

George Krause
  • 59
  • 1
  • 3
  • 11

3 Answers3

1

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

Community
  • 1
  • 1
Lyuben Todorov
  • 13,987
  • 5
  • 50
  • 69
  • Look at this: http://img560.imageshack.us/img560/1711/tomcatlib.png I am also using maven and in my webapp-war-folder is also this JDBC Class Driver :( I checked my URL its like: 'jdbc:derby://localhost:1521/app;create=true' I dont know who i can solve this problem...i already read all topics you advised to me :( – George Krause Mar 27 '13 at 08:38
0

I had an incorrect jdbc url like this:

Wrong!

jdbc:jtds://myserver:port;databaseName=abc

Correct:

jdbc://myserver:port;databaseName=abc

(removed the jtds: part...)

vikingsteve
  • 38,481
  • 23
  • 112
  • 156
0

Did you set the jdbc driver's path? When you use Oracle Database, you need to set the jar file (jdbc driver) path to "CLASSPATH".

Zen
  • 11
  • 1