File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes maven classpath - driver not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "maven classpath - driver not found" Watch "maven classpath - driver not found" New topic
Author

maven classpath - driver not found

T Mishra
Ranch Hand

Joined: Apr 04, 2006
Posts: 107

I am trying to generate entities using hbm2java using maven. However I get this error, It is quiet evident that postgres driver jar is missing but its present in the maven repository. Setting the dependency scope as runtime too did not solve the problem.
I've added the dependency under hibernate3-maven-plugin. What am I missing ?


Thanks,
Tushar (SCJP 1.5)
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

Which goal are you running for the hibernate plugin?

Anyway, I suspect that the issue has to do with the <scope> - I doubt that the hibernate goal is running as part of a phase that uses runtime scope. You should either remove the scope for the postgresql dependency, or change it to 'compile'. If that doesn't work, try moving the dependency to the project's dependency list.

JBoss In Action
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2051
    
  22

Runtime dependencies are only added into test classpath. Maven doesn't add it to the compile classpath. Compile time plugins look at compile classpath.

You can do 1 of 2 things
a) Set the scope to of postgre driver to provided. This will include the jar in compile and and test, but the jar won't be packaged
b) You can add a dependency tag to a plugin to add a dependency just for that plugin. So, you can add a dependency to postgre driver inside the hibernate3-maven-plugin



T Mishra
Ranch Hand

Joined: Apr 04, 2006
Posts: 107

Hi Peter,

Which goal are you running for the hibernate plugin?

I am running mvn hibernate3:hbm2java. It gets called during the phase generate-sources.

I tried running it with the default scope - compile. I also moved it to project dependency. However, I get the same error message

Hi Jayesh,

Option a) does not allow to set scope as provided

option b) I am not clear as to where it should be added ? At present, the dependency is already added for the plugin - hibernate3-maven-plugin

Thanks to both of you for looking into the problem.

- Tushar
T Mishra
Ranch Hand

Joined: Apr 04, 2006
Posts: 107

Here's my POM

hibernate.properties
T Mishra
Ranch Hand

Joined: Apr 04, 2006
Posts: 107

I also referred to this link here

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

Run Maven with the -X option, then it should tell you how the classpath is set up for running that goal. Perhaps that will give a clue.
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2051
    
  22

Ahh this is not a maven problem

Change hibernate.connection.url = jdbc:postgres://localhost:5433/postgres to hibernate.connection.url = jdbc:postgressql://localhost:5433/postgres

T Mishra
Ranch Hand

Joined: Apr 04, 2006
Posts: 107

This worked . I'm such a fool.

Thanks Jayesh and Peter !!
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2051
    
  22

No worries. Everyone has done a typo in JDBC URL atleast once in their life. And if you haven't you are way overdue
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: maven classpath - driver not found
 
Similar Threads
jstl in eclipse with maven
Need com.thoughtworks.xstream.annotations
Incorrect hibernate version or maven ignore and didn't download hibernate jar file.
Could not resolve dependencies for maven project
Could not resolve dependencies