• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting Error

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 :

 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic