Im new to hibernate, While im tring my first program with struts2 at that time i got this error how to solve this.
Awaiting for replay:
In Tomcat Server While Starting:
Quote:
INFO: Named query checking : enabled
Jan 9, 2011 1:11:14 PM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
######### HIBERNATE SP EXECEPTION #########
Jan 9, 2011 1:11:16 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
While Accessing file at that time
Quote:
java.lang.NullPointerException
com.treselle.sp.examples.hsex1.customer.action.CustomerAction.listCustomer(CustomerAction.java:82)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Customer Action file contains;
Code:
SessionFactory sessionFactory =
(SessionFactory) ServletActionContext.getServletContext().getAttribute(HibernateListener.KEY_NAME);
System.out.println("^^^^^^^^^^^^^^^^ sessionFactory : "+ sessionFactory);
Session session = sessionFactory.openSession(); //line 82
my hbm file
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.treselle.sp.examples.hsex1.customer.model.Customer"
table="customer" catalog="sample">
<id name="customerId" type="java.lang.Long">
<column name="CUSTOMER_ID" />
<generator class="identity" />
</id>
<property name="name" type="string">
<column name="NAME" length="45" not-null="true" />
</property>
<property name="address" type="string">
<column name="ADDRESS" not-null="true" />
</property>
<property name="createdDate" type="timestamp">
<column name="CREATED_DATE" length="19" not-null="true" />
</property>
</class>
</hibernate-mapping>
My Entity Pojo:
Code:
package com.treselle.sp.examples.hibernatestruts.customer.model;
import java.util.Date;
/**
*
* @author prakash
*/
public class Customer implements java.io.Serializable {
private Long customerId;
private String name;
private String address;
private Date createdDate;
public Customer()
{
}
public Customer(String name, String address, Date createdDate)
{
this.name = name;
this.address = address;
this.createdDate = createdDate;
}
public Long getCustomerId()
{
return this.customerId;
}
public void setCustomerId(Long customerId)
{
this.customerId = customerId;
}
public String getName()
{
return this.name;
}
public void setName(String name)
{
this.name = name;
}
public String getAddress()
{
return this.address;
}
public void setAddress(String address)
{
this.address = address;
}
public Date getCreatedDate()
{
return this.createdDate;
}
public void setCreatedDate(Date createdDate)
{
this.createdDate = createdDate;
}
}