-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: Bugs in tutorial
PostPosted: Wed Jul 22, 2009 6:07 am 
Newbie

Joined: Wed Jul 22, 2009 5:47 am
Posts: 2
Hi, i think i found some bugs in tutorial. I want to learn Hibernate but i'm stuck at very beginning of tutorial :[

1st bug:
http://docs.jboss.org/hibernate/stable/core/reference/en/html/tutorial.html#tutorial-associations-unidirset

Database schema in that point is completely destroyed.

Second thing. I have pasted every file as is said in tutorial and when in http://docs.jboss.org/hibernate/stable/core/reference/en/html/tutorial.html#tutorial-firstapp-mvn it says that after mvn compile it should compile files it's giving me error:
Code:
D:\hibernateTutorial>mvn compile
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: org.hibernate.tutorials:hibernate-tutorial
POM Location: D:\hibernateTutorial\pom.xml
Validation Messages:

    [0]  'dependencies.dependency.version' is missing for org.hibernate:hibernate-core:jar
    [1]  'dependencies.dependency.version' is missing for javax.servlet:servlet-api:jar
    [2]  'dependencies.dependency.version' is missing for org.slf4j:slf4j-simple:jar
    [3]  'dependencies.dependency.version' is missing for javassist:javassist:jar


Reason: Failed to validate POM for project org.hibernate.tutorials:hibernate-tutorial at D:\hibernateTutorial\pom.xml


[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Failed to validate POM for project org.hibernate.tutorials:hibernate-tutorial at D:\hibernateTutorial\pom.xml
        at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:432)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:300)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:41)
        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)
Caused by: org.apache.maven.project.InvalidProjectModelException: Failed to validate POM for project org.hibernate.tutorials:hibernate-tutorial at D:\hibernateTutorial\pom.xml
        at org.apache.maven.project.DefaultMavenProjectBuilder.processProjectLogic(DefaultMavenProjectBuilder.java:1077)
        at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:880)
        at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:508)
        at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
        at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:632)
        at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:515)
        at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:419)
        ... 12 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed Jul 22 12:06:04 CEST 2009
[INFO] Final Memory: 1M/4M
[INFO] ------------------------------------------------------------------------



My pom.xml file:

Code:
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>org.hibernate.tutorials</groupId>
    <artifactId>hibernate-tutorial</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <name>First Hibernate Tutorial</name>

    <build>
         <!-- we dont want the version to be part of the generated war file name -->
         <finalName>${artifactId}</finalName>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
        </dependency>

        <!-- Because this is a web app, we also have a dependency on the servlet api. -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
        </dependency>

        <!-- Hibernate uses slf4j for logging, for our purposes here use the simple backend -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
        </dependency>

        <!-- Hibernate gives you a choice of bytecode providers between cglib and javassist -->
        <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
        </dependency>
    </dependencies>

</project>


And it is EXACTLY the same as in http://docs.jboss.org/hibernate/stable/core/reference/en/html/tutorial.html#tutorial-firstapp-setup

Can you help me? :)


//EDIT: After experimenting i'm pretty sure that the presented in tutorial pom.xml file is wrong. It's missing <version> tags, but i don't know maven so can anyone present correct pom.xml? Should i report this errors in tutorial as bugs?


Top
 Profile  
 
 Post subject: Re: Bugs in tutorial
PostPosted: Tue Jul 28, 2009 3:11 pm 
Newbie

Joined: Tue Jul 28, 2009 2:51 pm
Posts: 1
Sounds like you're on the right track, I was having the same problem and once I called out versions in the dependencies it straightened out. The next "tree" you'll run head first into is that they forgot to mention putting the hsqldb dependency in the pom.xml file.

I am also going through the tutorial and keeping notes on everything that is wrong/missing. I also have the book Java Persistence with Hibernate but its coming up on 3 years old. It seems like finding detailed/accurate information for getting started is tough with a lot of projects. I'm just glad its open-source and essentially free once you've spent the blood, sweat, and tears trying to get started.


Top
 Profile  
 
 Post subject: Re: Bugs in tutorial
PostPosted: Wed Jul 29, 2009 6:00 am 
Newbie

Joined: Wed Jul 22, 2009 5:47 am
Posts: 2
Thanks for answer.
I must say that it is kind of unprofessional, Hibernate is few years old and it doesn't even have tutorial without bugs ON THE VERY BEGINNING. I have to know maven configuration to start completing tutorial.

I reported this bug on Hibernate JIRA but no one even looked at it.

I also have that book, but i wanted to start with something easier. I must say that i probably go back to book without reading tutorial...


Top
 Profile  
 
 Post subject: Re: Bugs in tutorial
PostPosted: Wed Sep 30, 2009 7:06 am 
Newbie

Joined: Wed Sep 30, 2009 7:02 am
Posts: 1
It seems, that the maven-repository does not contain any hibernate packages.

I added the jboss repo to the parent-pom and maven was able to resolve all dependencies again.

The parent-pom is located at:
Code:
  <hibernate-dir>\project\parent\pom.xml


Add the following lines:
Code:
<project>
  ...
  <repositories>
    <repository>
      <id>jboss repo server</id>
      <url>http://repository.jboss.org/maven2/</url>
    </repository>
  </repositories>
  ...
</project>


Top
 Profile  
 
 Post subject: Re: Bugs in tutorial
PostPosted: Wed Sep 30, 2009 5:06 pm 
Newbie

Joined: Wed Sep 30, 2009 1:03 pm
Posts: 1
Yes the tutorial does need updating but you have to bear in mind that it's open source and requires contributions from people doing this in their own spare time. I know it's painful when you're a beginner but things get easier with experience. One of the most important skills you can learn is how to get things working when you're lacking all the correct information...

Just replace the pom.xml with the below, these versions are available in the maven repository I just tested them.
Code:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

   <modelVersion>4.0.0</modelVersion>
   <groupId>org.hibernate.tutorials</groupId>
   <artifactId>hibernate-tutorial</artifactId>
   <version>1.0.0-SNAPSHOT</version>
   <name>First Hibernate Tutorial</name>

   <build>
      <!--
         we dont want the version to be part of the generated war file name
      -->
      <finalName>${artifactId}</finalName>
   </build>

   <dependencies>
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-core</artifactId>
         <version>3.3.2.GA</version>
      </dependency>

      <!--
         Because this is a web app, we also have a dependency on the servlet
         api.
      -->
      <dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>servlet-api</artifactId>
         <version>2.3</version>
      </dependency>

      <!--
         Hibernate uses slf4j for logging, for our purposes here use the
         simple backend
      -->
      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-simple</artifactId>
         <version>1.5.8</version>
      </dependency>

      <!--
         Hibernate gives you a choice of bytecode providers between cglib and
         javassist
      -->
      <dependency>
         <groupId>javassist</groupId>
         <artifactId>javassist</artifactId>
         <version>3.8.0.GA</version>
      </dependency>
      <dependency>
         <groupId>hsqldb</groupId>
         <artifactId>hsqldb</artifactId>
         <version>1.8.0.7</version>
      </dependency>
   </dependencies>

</project>


Top
 Profile  
 
 Post subject: Re: Bugs in tutorial
PostPosted: Tue Jan 19, 2010 8:11 pm 
Newbie

Joined: Fri Nov 14, 2008 2:12 pm
Posts: 7
Location: new york
jazzdup: thank you very much for the fixed POM. It worked perfectly.


Top
 Profile  
 
 Post subject: Re: Bugs in tutorial
PostPosted: Wed Jan 20, 2010 5:53 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
That the schema is destroyed each time you launch the application is not a bug!
It depends on how you set the property hbm2ddl.auto

Code:
<!-- Drop and re-create the database schema on startup -->
        <property name="hbm2ddl.auto">update</property>


Top
 Profile  
 
 Post subject: Re: Bugs in tutorial
PostPosted: Tue Dec 07, 2010 8:39 pm 
Newbie

Joined: Tue Nov 16, 2010 12:19 am
Posts: 9
Thank you enormously for the corrected POM. The 3.6CR2 docs still have a broken POM. Though an extremely experienced developer, I am new to both maven and hibernate, and I have wasted endless hours trying to get this tiny tutorial working.

I understand it's an open source project. I have a meta question, which in the Python world I would know how to answer since I work with the repositories there and post bugs extensively. (I hope someone is still watching this topic after all the time since it was commented on.) Suppose I suspect a corrected pom.xml has been posted, or corrections to that part of the documentation -- where and how would I look for that? I am completely clueless as to what it means for Hibernate to be maintained as Maven artifacts.


Top
 Profile  
 
 Post subject: Re: Bugs in tutorial
PostPosted: Wed Feb 09, 2011 4:57 pm 
Newbie

Joined: Wed Feb 09, 2011 4:55 pm
Posts: 1
How do you know which version to include? For example I believe Hibernate is up to version 3.6.1 now and I looked through the Maven repositories and couldn't find that.


Top
 Profile  
 
 Post subject: Re: Bugs in tutorial
PostPosted: Thu Feb 17, 2011 9:05 am 
Newbie

Joined: Thu Feb 17, 2011 8:46 am
Posts: 1
Point to latest Maven repository.

Modify maven settings.xml

Code:
<settings>
  ...
  <profiles>
    ...
    <profile>
      <id>jboss-public-repository</id>
      <repositories>
        <repository>
          <id>jboss-public-repository-group</id>
          <name>JBoss Public Maven Repository Group</name>
          <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
          <layout>default</layout>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>jboss-public-repository-group</id>
          <name>JBoss Public Maven Repository Group</name>
          <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
          <layout>default</layout>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>

  </profiles>

  <activeProfiles>
    <activeProfile>jboss-public-repository</activeProfile>
  </activeProfiles>
  ...
</settings>


Modify your pom.xml to use latest hibernate version

Code:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

   <modelVersion>4.0.0</modelVersion>
   <groupId>com.samples</groupId>
   <artifactId>hibernate-samples</artifactId>
   <version>1.0.0-SNAPSHOT</version>
   <name>First Hibernate Sample</name>

   <build>
      <!--
         we dont want the version to be part of the generated war file name
      -->
      <finalName>${artifactId}</finalName>
   </build>

   <dependencies>
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-core</artifactId>
       <version>3.6.1.Final</version>
      </dependency>

      <!--
         Because this is a web app, we also have a dependency on the servlet
         api.
      -->
      <dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>servlet-api</artifactId>
         <version>2.3</version>
      </dependency>

      <!--
         Hibernate uses slf4j for logging, for our purposes here use the
         simple backend
      -->
      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-simple</artifactId>
         <version>1.5.8</version>
      </dependency>

      <!--
         Hibernate gives you a choice of bytecode providers between cglib and
         javassist
      -->
      <dependency>
         <groupId>javassist</groupId>
         <artifactId>javassist</artifactId>
         <version>3.8.0.GA</version>
      </dependency>
      <dependency>
         <groupId>hsqldb</groupId>
         <artifactId>hsqldb</artifactId>
         <version>1.8.0.7</version>
      </dependency>
   </dependencies>

</project>


To know which version to use visit below link and see if the latest version of hibernate is added to maven repository

http://repository.jboss.org/nexus/content/groups/public-jboss/org/hibernate/hibernate-core/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.