-->
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.  [ 3 posts ] 
Author Message
 Post subject: Trouble with first Hibernate tutorial
PostPosted: Wed Jul 23, 2008 7:28 pm 
Newbie

Joined: Mon Jul 21, 2008 6:32 pm
Posts: 3
Hi all, I'm new to Hibernate and have downloaded the sample from here:

http://wiki.netbeans.org/HibernateAndWebApp

I have followed all the set-up instructions but can't get it to work. I have spent a long time trying to work it out but no luck :(

Thanks in advance.

Help please you kind people.

Hibernate version: 3.2.5

Mapping documents:

Actor.hbm.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class dynamic-insert="false" dynamic-update="false" mutable="true" name="dvdrental.Actor" optimistic-lock="version" polymorphism="implicit" select-before-update="false" table="actor">
<id column="actor_id" name="actorID">
<generator class="increment"/>
</id>
<property column="first_name" name="firstName" />
<property column="last_name" name="lastName" />
</class>
</hibernate-mapping>

Category.hbm.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class dynamic-insert="false" dynamic-update="false" mutable="true" name="dvdrental.Category" optimistic-lock="version" polymorphism="implicit" select-before-update="false" table="category">
<id column="category_id" name="categoryID">
<generator class="increment"/>
</id>
<property column="name" name="name" />
</class>
</hibernate-mapping>

Film.hbm.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class dynamic-insert="false" dynamic-update="false" mutable="true" name="dvdrental.Film" optimistic-lock="version" polymorphism="implicit" select-before-update="false" table="film">
<id column="film_id" name="filmID">
<generator class="increment"/>
</id>

<property column="description" name="description"/>
<property column="language_id" name="languageID"/>
<property column="last_update" name="lastUpdate"/>
<property column="length" name="length"/>
<property column="original_language_id" name="origLangID"/>
<property column="rating" name="rating"/>
<property column="release_year" name="releaseYear"/>
<property column="rental_duration" name="rentalDuration"/>
<property column="rental_rate" name="rentalRate"/>
<property column="special_features" name="specialFeatures"/>
<property column="title" name="title"/>

</class>
</hibernate-mapping

FilmActor.hbm.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class dynamic-insert="false" dynamic-update="false" mutable="true" name="dvdrental.FilmActor" optimistic-lock="version" polymorphism="implicit" select-before-update="false" table="film_actor">
<id column="actor_id" name="actorID">
<generator class="increment"/>
</id>
<property column="film_id" name="filmID" />
</class>
</hibernate-mapping>

FilmCategory.hbm.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class dynamic-insert="false" dynamic-update="false" mutable="true" name="dvdrental.FilmCategory" optimistic-lock="version" polymorphism="implicit" select-before-update="false" table="film_category">
<id column="category_id" name="categoryID">
<generator class="increment"/>
</id>
<property column="film_id" name="filmID" />
</class>
</hibernate-mapping>

Language.hbm.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class dynamic-insert="false" dynamic-update="false" mutable="true" name="dvdrental.Language" optimistic-lock="version" polymorphism="implicit" select-before-update="false" table="language">
<id column="language_id" name="languageID">
<generator class="increment"/>
</id>

<property column="name" name="language" />
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close(): Not sure cos I can't find sessionFactory or openSession!

Full stack trace of any exception that occurs:

The exception occurs when the following line executes:

org.hibernate.Transaction tx = session.beginTransaction();


exception

org.apache.jasper.JasperException: java.lang.NullPointerException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

root cause

java.lang.NullPointerException
org.apache.jsp.index_jsp._jspService(index_jsp.java:125)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)


Name and version of the database you are using: 5.0.51

The generated SQL (show_sql=true): ?

Debug level Hibernate log excerpt: ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 3:50 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Here's a much simpler tutorial. I think you'll find it very helpful in getting you started with Hibernate:

http://jpa.ezhibernate.com/Javacode/learn.jsp?tutorial=01howtogetstartedwithhibernate

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 28, 2008 5:05 pm 
Newbie

Joined: Mon Jul 21, 2008 6:32 pm
Posts: 3
Not bad tutorial, very straightforward, cheers dude.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.