• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting Error

 
anagha pendse
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone ,
I am new to Hibernate - and thought I would try out a ready made example
Here are some code excerpts :

In the JSP :
=============================
<%@ page import="hib.Item" %>
<%@ page import="hib.ItemService" %>

<%
Item item = new Item();

item.setDescription("Desc");
item.setName("Name");
// this line gives an error
ItemService.getInstance().addItem(item);


%>
=============================

" Item " is a simple Java Bean
The problem is when the code tries to get a "Session" Object

Here is the xml file : "Item.hbm.xml"
======================================
<hibernate-mapping>
<class name="Item" table="item">
<id name="id" column="id" type="java.lang.Long" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="name" column="name" type="java.lang.String"/>
<property name="description" column="description" type="java.lang.String"/>
</class>
</hibernate-mapping>
======================================

The error that I get is :

 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe it's telling you that it cannot find the mapping file on the classpath as opposed to finding it and it having a syntax error. Have you made sure it's available?

When starting with a new technology, I find it helpful to avoid mixing it with other technologies at once. Instead, try to introduce one new thing at a time. In this case, I'd get Hibernate working in a plain old Java main() method rather than combining it with a JSP/servlet container.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic