views:

362

answers:

2

I am novice to maven (as well as to hibernate) but want to learn both. I have downloaded a sample project from hibernate.org and now trying to compile it with maven but getting following error:

[INFO] Scanning for projects... Downloading: http://repo1.maven.org/maven2/org/hibernate/hibernate-parent/3.5.2- Final/hibernate-parent-3.5.2-Final.pom [INFO] Unable to find resource 'org.hibernate:hibernate-parent:pom:3.5.2-Final' in repository central (http://repo1.maven.org/maven2) [INFO] ------------------------------------------------------------------------ [ERROR] FATAL ERROR [INFO] ------------------------------------------------------------------------ [INFO] Error building POM (may not be this project's POM).

Project ID: org.hibernate:hibernate-tutorials:pom:null

Reason: Cannot find parent: org.hibernate:hibernate-parent for project: org.hibe rnate:hibernate-tutorials:pom:null for project org.hibernate:hibernate-tutorials :pom:null

[INFO] ------------------------------------------------------------------------ [INFO] Trace org.apache.maven.reactor.MavenExecutionException: Cannot find parent: org.hibern ate:hibernate-parent for project: org.hibernate:hibernate-tutorials:pom:null for project org.hibernate:hibernate-tutorials:pom:null at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:404) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:272) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138) at org.apache.maven.cli.MavenCli.main(MavenCli.java:362) at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:6 0) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.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)

Caused by: org.apache.maven.project.ProjectBuildingException: Cannot find parent : org.hibernate:hibernate-parent for project: org.hibernate:hibernate-tutorials: pom:null for project org.hibernate:hibernate-tutorials:pom:null at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(D efaultMavenProjectBuilder.java:1396) at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(Def aultMavenProjectBuilder.java:823) at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFi leInternal(DefaultMavenProjectBuilder.java:508) at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMave nProjectBuilder.java:200) at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:604) at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:487) at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:391) ... 12 more Caused by: org.apache.maven.project.ProjectBuildingException: POM 'org.hibernate :hibernate-parent' not found in repository: Unable to download the artifact from any repository

org.hibernate:hibernate-parent:pom:3.5.2-Final

from the specified remote repositories: central (http://repo1.maven.org/maven2)

for project org.hibernate:hibernate-parent at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepo sitory(DefaultMavenProjectBuilder.java:605) at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(D efaultMavenProjectBuilder.java:1392) ... 18 more Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException: Unable to download the artifact from any repository

org.hibernate:hibernate-parent:pom:3.5.2-Final

from the specified remote repositories: central (http://repo1.maven.org/maven2)

    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(De

faultArtifactResolver.java:228) at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(De faultArtifactResolver.java:90) at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepo sitory(DefaultMavenProjectBuilder.java:558) ... 19 more Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to downl oad the artifact from any repository at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(Def aultWagonManager.java:404) at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(De faultArtifactResolver.java:216) ... 21 more

Looks it is trying to download libraries from the web? can I not provide all jars required by my sample project on local drive? Is there any quick solution of my problem, to start with? or I should study maven and hibernate in details before I start it?

+4  A: 

Hibernate 3.5.2-Final is not available in the Maven central repository but is available in JBoss repository. So add the following to your pom.xml (or your settings.xml):

<repositories>
  <repository>
    <id>jboss-public-repository-group</id>
    <name>JBoss Public Repository Group</name>
    <url>http://repository.jboss.org/nexus/content/groups/public&lt;/url&gt;
  </repository>
  ...
</repositories>

See also

Pascal Thivent
Thank you Pascal, it works!
Leslie Norman
+1 for the question and +1 for the answer:Thank from my side as well, I was almost getting crazy as I was still using http://repository.jboss.com/maven2 repository and in there only 3.5.1 Final is included :-(
Nils Schmidt
@SJP @Nils You're welcome.
Pascal Thivent
+1  A: 

I should study maven and hibernate in details before I start it?

Yes. Maven can be simple, or extremely complex depending on how far you want to go with it. Hibernate can be complex to set up if you're doing more than the basics. I'd suggest learning one at a time.

Looks it is trying to download libraries from the web? can I not provide all jars required by my sample project on local drive?

Yes and Yes. By default (I believe) maven both looks on your local filesystem and out on the interwebs. It attempts to keep your local copy in sync. But you can set it up to just use your local repository if you'd like.

Is there any quick solution of my problem, to start with?

Maybe. Change the version number from 3.5.2-Final to 3.3.2.GA for hibernate-parent.

Quotidian
There is no need to workaround the issue by downgrading the version(s) (which may simply not work if the sample requires a JPA 2.0 implementation), just add the required repository for Hibernate 3.5.2-Final...
Pascal Thivent
Which I why I said maybe. Since the OP is a maven novice I went for a simpler solution off the bat. If the POM doesn't contain a repo reference it clearly needs, who's to say downgrading won't work?
Quotidian