How to get hibernate3-maven-plugin hbm2ddl to find JDBC driver?
Posted
by HDave
on Stack Overflow
See other posts from Stack Overflow
or by HDave
Published on 2010-05-14T02:17:31Z
Indexed on
2010/05/14
2:24 UTC
Read the original article
Hit count: 383
I have a Java project I am building with Maven. I am now trying to get the hibernate3-maven-plugin to run the hbm2ddl tool to generate a schema.sql file I can use to create the database schema from my annotated domain classes. This is a JPA application that uses Hibernate as the provider.
In my persistence.xml file I call out the mysql driver:
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
When I run Maven, I see it processing all my classes, but when it goes to output the schema, I get the following error:
ERROR org.hibernate.connection.DriverManagerConnectionProvider - JDBC Driver class not found: com.mysql.jdbc.Driver
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
I have the MySQL driver as a dependency of this module. However it seems like the hbm2ddl tool cannot find it. I would have guessed that the Maven plugin would have known to search the local Maven file repository for this driver. What gives?
The relevant part of my pom.xml is this:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>hbm2ddl</goal>
</goals>
</execution>
</executions>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>jpaconfiguration</implementation>
</component>
</components>
<componentProperties>
<persistenceunit>my-unit</persistenceunit>
</componentProperties>
</configuration>
</plugin>
© Stack Overflow or respective owner