Re: No suitable driver found

From: John Dunlap <john(dot)dunlap(at)exceter(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: No suitable driver found
Date: 2009-07-27 20:20:22
Message-ID: 4A6E0C06.9030206@exceter.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Thanks for that shove in the right direction Dave. The problem had
nothing to do with it being a web application (because you don't have to
deploy it to generate a database schema) but you did put me onto the
right train of thought. The problem was that although I had added the
postgresql jdbc driver to my maven project as a dependency, I hadn't
added it as a dependency for the hibernate3-maven-plugin.

Dave Cramer wrote:
> so when you extract the war where is the postgresql jar ?
>
> If this is a webapp then it has to be in a specific place.
>
> DAve
>
> On Mon, Jul 27, 2009 at 1:57 PM, John Dunlap <john(dot)dunlap(at)exceter(dot)com
> <mailto:john(dot)dunlap(at)exceter(dot)com>> wrote:
>
> This is the classpath that maven is using,
>
> [myusername(at)myhostname myproject]$ mvn cpprinter:print
> [INFO] Scanning for projects...
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building Unnamed - com.mysite:myproject:war:0.0.1-SNAPSHOT
> [INFO] task-segment: [cpprinter:print] (aggregator-style)
> [INFO]
> ------------------------------------------------------------------------
> Downloading:
> http://repo1.maven.org/maven2/opensymphony/quartz/1.6.3/quartz-1.6.3.pom
> [INFO] Unable to find resource 'opensymphony:quartz:pom:1.6.3' in
> repository central (http://repo1.maven.org/maven2)
> [INFO] [cpprinter:print]
>
> =================== RUNTIME CLASSPATH ====================
> /home/myusername/workspace/myproject/target/classes
> /home/myusername/.m2/repository/org/htmlparser/htmlparser/1.6/htmlparser-1.6.jar
> /home/myusername/.m2/repository/org/slf4j/slf4j-jcl/1.5.6/slf4j-jcl-1.5.6.jar
> /home/myusername/.m2/repository/org/slf4j/slf4j-api/1.5.6/slf4j-api-1.5.6.jar
> /home/myusername/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
> /home/myusername/.m2/repository/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar
> /home/myusername/.m2/repository/org/springframework/spring-orm/2.5.6.SEC01/spring-orm-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
> /home/myusername/.m2/repository/org/springframework/spring-beans/2.5.6.SEC01/spring-beans-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/org/springframework/spring-core/2.5.6.SEC01/spring-core-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/org/springframework/spring-context/2.5.6.SEC01/spring-context-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/org/springframework/spring-tx/2.5.6.SEC01/spring-tx-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/org/apache/tiles/tiles-api/2.0.6/tiles-api-2.0.6.jar
> /home/myusername/.m2/repository/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar
> /home/myusername/.m2/repository/org/apache/tiles/tiles-core/2.0.6/tiles-core-2.0.6.jar
> /home/myusername/.m2/repository/commons-digester/commons-digester/1.8/commons-digester-1.8.jar
> /home/myusername/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar
> /home/myusername/.m2/repository/org/apache/tiles/tiles-jsp/2.0.6/tiles-jsp-2.0.6.jar
> /home/myusername/.m2/repository/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA.jar
> <http://3.4.0.GA/hibernate-annotations-3.4.0.GA.jar>
> /home/myusername/.m2/repository/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA.jar
> <http://1.0.2.GA/ejb3-persistence-1.0.2.GA.jar>
> /home/myusername/.m2/repository/org/hibernate/hibernate-commons-annotations/3.1.0.GA/hibernate-commons-annotations-3.1.0.GA.jar
> <http://3.1.0.GA/hibernate-commons-annotations-3.1.0.GA.jar>
> /home/myusername/.m2/repository/org/hibernate/hibernate-core/3.3.0.SP1/hibernate-core-3.3.0.SP1.jar
> /home/myusername/.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar
> /home/myusername/.m2/repository/commons-collections/commons-collections/3.2/commons-collections-3.2.jar
> /home/myusername/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar
> /home/myusername/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar
> /home/myusername/.m2/repository/javax/transaction/jta/1.1/jta-1.1.jar
> /home/myusername/.m2/repository/org/springframework/security/spring-security-core/2.0.4/spring-security-core-2.0.4.jar
> /home/myusername/.m2/repository/org/springframework/spring-aop/2.0.8/spring-aop-2.0.8.jar
> /home/myusername/.m2/repository/org/springframework/spring-support/2.0.8/spring-support-2.0.8.jar
> /home/myusername/.m2/repository/commons-codec/commons-codec/1.3/commons-codec-1.3.jar
> /home/myusername/.m2/repository/org/springframework/spring-web/2.5.6.SEC01/spring-web-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/org/springframework/spring-webmvc/2.5.6.SEC01/spring-webmvc-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/org/springframework/spring-context-support/2.5.6.SEC01/spring-context-support-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/org/springframework/spring-dao/2.0.8/spring-dao-2.0.8.jar
> /home/myusername/.m2/repository/org/springframework/spring-jdbc/2.5.6.SEC01/spring-jdbc-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/javassist/javassist/3.8.0.GA/javassist-3.8.0.GA.jar
> <http://3.8.0.GA/javassist-3.8.0.GA.jar>
> /home/myusername/.m2/repository/opensymphony/quartz/1.6.3/quartz-1.6.3.jar
> /home/myusername/.m2/repository/javax/mail/mail/1.4.1/mail-1.4.1.jar
> /home/myusername/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar
> /home/myusername/.m2/repository/postgresql/postgresql/8.3-603.jdbc4/postgresql-8.3-603.jdbc4.jar
> ===========================================================
>
>
> ==================== TEST CLASSPATH ======================
> /home/myusername/workspace/myproject/target/test-classes
> /home/myusername/workspace/myproject/target/classes
> /home/myusername/.m2/repository/org/htmlparser/htmlparser/1.6/htmlparser-1.6.jar
> /home/myusername/.m2/repository/org/slf4j/slf4j-jcl/1.5.6/slf4j-jcl-1.5.6.jar
> /home/myusername/.m2/repository/org/slf4j/slf4j-api/1.5.6/slf4j-api-1.5.6.jar
> /home/myusername/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
> /home/myusername/.m2/repository/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar
> /home/myusername/.m2/repository/org/springframework/spring-orm/2.5.6.SEC01/spring-orm-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
> /home/myusername/.m2/repository/org/springframework/spring-beans/2.5.6.SEC01/spring-beans-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/org/springframework/spring-core/2.5.6.SEC01/spring-core-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/org/springframework/spring-context/2.5.6.SEC01/spring-context-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/org/springframework/spring-tx/2.5.6.SEC01/spring-tx-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/org/apache/tiles/tiles-api/2.0.6/tiles-api-2.0.6.jar
> /home/myusername/.m2/repository/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar
> /home/myusername/.m2/repository/org/apache/tiles/tiles-core/2.0.6/tiles-core-2.0.6.jar
> /home/myusername/.m2/repository/commons-digester/commons-digester/1.8/commons-digester-1.8.jar
> /home/myusername/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar
> /home/myusername/.m2/repository/org/apache/tiles/tiles-jsp/2.0.6/tiles-jsp-2.0.6.jar
> /home/myusername/.m2/repository/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA.jar
> <http://3.4.0.GA/hibernate-annotations-3.4.0.GA.jar>
> /home/myusername/.m2/repository/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA.jar
> <http://1.0.2.GA/ejb3-persistence-1.0.2.GA.jar>
> /home/myusername/.m2/repository/org/hibernate/hibernate-commons-annotations/3.1.0.GA/hibernate-commons-annotations-3.1.0.GA.jar
> <http://3.1.0.GA/hibernate-commons-annotations-3.1.0.GA.jar>
> /home/myusername/.m2/repository/org/hibernate/hibernate-core/3.3.0.SP1/hibernate-core-3.3.0.SP1.jar
> /home/myusername/.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar
> /home/myusername/.m2/repository/commons-collections/commons-collections/3.2/commons-collections-3.2.jar
> /home/myusername/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar
> /home/myusername/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar
> /home/myusername/.m2/repository/javax/transaction/jta/1.1/jta-1.1.jar
> /home/myusername/.m2/repository/org/springframework/security/spring-security-core/2.0.4/spring-security-core-2.0.4.jar
> /home/myusername/.m2/repository/org/springframework/spring-aop/2.0.8/spring-aop-2.0.8.jar
> /home/myusername/.m2/repository/org/springframework/spring-support/2.0.8/spring-support-2.0.8.jar
> /home/myusername/.m2/repository/commons-codec/commons-codec/1.3/commons-codec-1.3.jar
> /home/myusername/.m2/repository/org/springframework/spring-web/2.5.6.SEC01/spring-web-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/org/springframework/spring-webmvc/2.5.6.SEC01/spring-webmvc-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/org/springframework/spring-context-support/2.5.6.SEC01/spring-context-support-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/org/springframework/spring-dao/2.0.8/spring-dao-2.0.8.jar
> /home/myusername/.m2/repository/org/springframework/spring-jdbc/2.5.6.SEC01/spring-jdbc-2.5.6.SEC01.jar
> /home/myusername/.m2/repository/javassist/javassist/3.8.0.GA/javassist-3.8.0.GA.jar
> <http://3.8.0.GA/javassist-3.8.0.GA.jar>
> /home/myusername/.m2/repository/opensymphony/quartz/1.6.3/quartz-1.6.3.jar
> /home/myusername/.m2/repository/javax/mail/mail/1.4.1/mail-1.4.1.jar
> /home/myusername/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar
> /home/myusername/.m2/repository/postgresql/postgresql/8.3-603.jdbc4/postgresql-8.3-603.jdbc4.jar
> ===========================================================
>
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD SUCCESSFUL
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 1 second
> [INFO] Finished at: Mon Jul 27 13:53:14 EDT 2009
> [INFO] Final Memory: 15M/209M
> [INFO]
> ------------------------------------------------------------------------
> [myusername(at)myhostname myproject]$
>
> I'm using maven for dependency management. If the postgresql
> artifact needed other jars, maven would have automatically
> downloaded them and put them into the classpath (unless the
> pom.xml file in the central nexus repository is broken). Also, I
> get the same error when I run the hibernate3:hbm2ddl goal on
> command line (IE: without eclipse):
>
> [myusername(at)myhostname myproject]$ mvn clean package
> hibernate3:hbm2ddl
> [INFO] Scanning for projects...
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building Unnamed - com.mysite:myproject:war:0.0.1-SNAPSHOT
> [INFO] task-segment: [clean, package, hibernate3:hbm2ddl]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] [clean:clean]
> [INFO] Deleting directory /home/myusername/workspace/myproject/target
> [INFO] [resources:resources]
> [WARNING] Using platform encoding (UTF-8 actually) to copy
> filtered resources, i.e. build is platform dependent!
> [INFO] Copying 3 resources
> Downloading:
> http://repo1.maven.org/maven2/opensymphony/quartz/1.6.3/quartz-1.6.3.pom
> [INFO] Unable to find resource 'opensymphony:quartz:pom:1.6.3' in
> repository central (http://repo1.maven.org/maven2)
> [INFO] [compiler:compile]
> [INFO] Compiling 8 source files to
> /home/myusername/workspace/myproject/target/classes
> [INFO] [resources:testResources]
> [WARNING] Using platform encoding (UTF-8 actually) to copy
> filtered resources, i.e. build is platform dependent!
> [INFO] Copying 0 resource
> [INFO] [compiler:testCompile]
> [INFO] Nothing to compile - all classes are up to date
> [INFO] [surefire:test]
> [INFO] Surefire report directory:
> /home/myusername/workspace/myproject/target/surefire-reports
>
> -------------------------------------------------------
> T E S T S
> -------------------------------------------------------
> There are no tests to run.
>
> Results :
>
> Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
>
> [INFO] [war:war]
> [INFO] Packaging webapp
> [INFO] Assembling webapp[myproject] in
> [/home/myusername/workspace/myproject/target/myproject-0.0.1-SNAPSHOT]
> [INFO] Processing war project
> [INFO] Copying webapp
> resources[/home/myusername/workspace/myproject/src/main/webapp]
> [INFO] Webapp assembled in[162 msecs]
> [INFO] Building war:
> /home/myusername/workspace/myproject/target/myproject-0.0.1-SNAPSHOT.war
> [INFO] Preparing hibernate3:hbm2ddl
> [INFO] [resources:resources]
> [WARNING] Using platform encoding (UTF-8 actually) to copy
> filtered resources, i.e. build is platform dependent!
> [INFO] Copying 3 resources
> [INFO] [hibernate3:hbm2ddl]
> [INFO] Configuration XML file loaded:
> file:/home/myusername/workspace/myproject/src/main/resources/hibernate.cfg.xml
> 13:40:27,339 INFO org.hibernate.cfg.annotations.Version -
> Hibernate Annotations 3.4.0.GA <http://3.4.0.GA>
> 13:40:27,350 INFO org.hibernate.cfg.Environment - Hibernate
> 3.3.1.GA <http://3.3.1.GA>
> 13:40:27,353 INFO org.hibernate.cfg.Environment -
> hibernate.properties not found
> 13:40:27,356 INFO org.hibernate.cfg.Environment - Bytecode
> provider name : javassist
> 13:40:27,360 INFO org.hibernate.cfg.Environment - using JDK 1.4
> java.sql.Timestamp handling
> 13:40:27,399 INFO org.hibernate.annotations.common.Version -
> Hibernate Commons Annotations 3.1.0.GA <http://3.1.0.GA>
> [INFO] Configuration XML file loaded:
> file:/home/myusername/workspace/myproject/src/main/resources/hibernate.cfg.xml
> 13:40:27,400 INFO org.hibernate.cfg.Configuration - configuring
> from url:
> file:/home/myusername/workspace/myproject/src/main/resources/hibernate.cfg.xml
> 13:40:27,525 INFO org.hibernate.cfg.Configuration - Configured
> SessionFactory: null
> [INFO] No hibernate properties file loaded.
> 13:40:27,570 INFO org.hibernate.cfg.AnnotationBinder - Binding
> entity from annotated class: com.mysite.entity.Batch
> 13:40:27,600 INFO org.hibernate.cfg.annotations.EntityBinder -
> Bind entity com.mysite.entity.Batch on table BATCHES
> 13:40:27,671 INFO org.hibernate.cfg.AnnotationBinder - Binding
> entity from annotated class: com.mysite.entity.Character
> 13:40:27,672 INFO org.hibernate.cfg.annotations.EntityBinder -
> Bind entity com.mysite.entity.Character on table CHARACTERS
> 13:40:27,674 INFO org.hibernate.cfg.AnnotationBinder - Binding
> entity from annotated class: com.mysite.entity.Sighting
> 13:40:27,674 INFO org.hibernate.cfg.annotations.EntityBinder -
> Bind entity com.mysite.entity.Sighting on table SIGHTINGS
> 13:40:27,679 INFO org.hibernate.cfg.AnnotationBinder - Binding
> entity from annotated class: com.mysite.entity.Area
> 13:40:27,679 INFO org.hibernate.cfg.annotations.EntityBinder -
> Bind entity com.mysite.entity.Area on table AREAS
> 13:40:27,711 INFO org.hibernate.cfg.annotations.CollectionBinder
> - Mapping collection: com.mysite.entity.Character.sightings ->
> SIGHTINGS
> 13:40:27,712 INFO org.hibernate.cfg.annotations.CollectionBinder
> - Mapping collection: com.mysite.entity.Batch.sightings -> SIGHTINGS
> 13:40:27,714 INFO org.hibernate.cfg.AnnotationConfiguration -
> Hibernate Validator not found: ignoring
> 13:40:27,722 INFO org.hibernate.dialect.Dialect - Using dialect:
> org.hibernate.dialect.PostgreSQLDialect
> 13:40:27,742 INFO org.hibernate.tool.hbm2ddl.SchemaExport -
> Running hbm2ddl schema export
> 13:40:27,742 INFO org.hibernate.tool.hbm2ddl.SchemaExport -
> exporting generated schema to database
> 13:40:27,744 INFO
> org.hibernate.connection.DriverManagerConnectionProvider - Using
> Hibernate built-in connection pool (not for production use!)
> 13:40:27,744 INFO
> org.hibernate.connection.DriverManagerConnectionProvider -
> Hibernate connection pool size: 20
> 13:40:27,744 INFO
> org.hibernate.connection.DriverManagerConnectionProvider -
> autocommit mode: false
> 13:40:27,745 INFO
> org.hibernate.connection.DriverManagerConnectionProvider - using
> driver: org.postgresql.Driver at URL:
> jdbc:postgresql://localhost:5432/mydatabase
> 13:40:27,745 INFO
> org.hibernate.connection.DriverManagerConnectionProvider -
> connection properties: {user=myusername, password=****}
> 13:40:27,756 ERROR org.hibernate.tool.hbm2ddl.SchemaExport -
> schema export unsuccessful
>
> java.sql.SQLException: No suitable driver found for
> jdbc:postgresql://localhost:5432/mydatabase
> at java.sql.DriverManager.getConnection(DriverManager.java:602)
> at java.sql.DriverManager.getConnection(DriverManager.java:154)
> at
> org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
> at
> org.hibernate.tool.hbm2ddl.ManagedProviderConnectionHelper.prepare(ManagedProviderConnectionHelper.java:52)
> at
> org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:252)
> at
> org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:211)
> at
> org.codehaus.mojo.hibernate3.exporter.Hbm2DDLExporterMojo.doExecute(Hbm2DDLExporterMojo.java:112)
> at
> org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:152)
> at
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:553)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:523)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
> at
> org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
> at org.apache.maven.cli.MavenCli.main(MavenCli.java:356)
>
> 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
> org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
> at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
> at
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
> at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> [WARNING] 1 errors occurred while performing <hbm2ddl>.
> [ERROR] Error #1: java.sql.SQLException: No suitable driver found
> for jdbc:postgresql://localhost:5432/mydatabase
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD SUCCESSFUL
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 5 seconds
> [INFO] Finished at: Mon Jul 27 13:40:27 EDT 2009
> [INFO] Final Memory: 38M/336M
> [INFO]
> ------------------------------------------------------------------------
> [myusername(at)myhostname myproject]$
>
>
>
> Dave Cramer wrote:
>
> When you run something in eclipse you should be able to see
> the entire classpath in the run string. It's undoubtedly
> something missing in the classpath.
>
> Dave
>
>
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc(at)postgresql(dot)org
> <mailto:pgsql-jdbc(at)postgresql(dot)org>)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2009-07-28 05:40:41 Re: Encoding from CopyManager.copyIn()
Previous Message John Dunlap 2009-07-27 17:57:39 Re: No suitable driver found