Ola pessoal, estou com uma duvida, sou iniciante em VRaptor
Tenho uma classe GenericDAO/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package br.com.amazonas.sistecam.dao;
import br.com.amazonas.sistecam.hibernate.CriadorSession;
import br.com.amazonas.sistecam.hibernate.HibernateUtil;
import br.com.caelum.vraptor.ioc.Component;
import java.util.Date;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
/**
*
* @author Cássio Thadeu
*/
@Component
public class GenericDAO<T> implements DAO<T>{
private Session session;
private Transaction tx;
private Class<T> classe;
public GenericDAO(Class<T> classe, CriadorSession session){
this.classe = classe;
this.session = session.getInstance();
}
@Override
public void insert(T classe) {
try{
tx = session.beginTransaction();
session.save(classe);
tx.commit();
}
catch(HibernateException ex){
tx.rollback();
throw ex;
}
}
@Override
public void update(T classe) {
try{
tx = session.beginTransaction();
session.update(classe);
tx.commit();
}
catch(HibernateException ex){
tx.rollback();
throw ex;
}
}
@Override
public void delete(T classe) {
try{
tx = session.beginTransaction();
session.update(classe);
tx.commit();
}
catch(HibernateException ex){
tx.rollback();
throw ex;
}
}
@Override
public List<T> findAll() {
try{
Criteria c = session.createCriteria(this.classe);
return c.list();
}
catch(HibernateException ex){
tx.rollback();
throw ex;
}
}
public List<T> findByName(Object coluna ,Object d) {
try{
Criteria c = session.createCriteria(this.classe);
c.add(Restrictions.ilike(coluna.toString(), "%"+d.toString()+"%"));
c.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
c.addOrder(Order.asc(coluna.toString()));
return c.list();
}
catch(HibernateException ex){
throw ex;
}
}
public T findByID(Integer id) throws HibernateException {
try{
return (T) session.get(this.classe, id);
}
catch(HibernateException ex){
throw ex;
}
}
public void saveOrUpdate(T clazz) throws HibernateException {
try{
tx = session.beginTransaction();
session.saveOrUpdate(clazz);
tx.commit();
}
catch(HibernateException ex){
tx.rollback();
throw ex;
}
}
public List<T> findByBetweenDate(String namedQuery, Date inicio, Date fim) {
try{
tx = session.beginTransaction();
return session.getNamedQuery(namedQuery).setDate("inicio", inicio).setDate("fim", fim).list();
}
catch(HibernateException ex){
tx.rollback();
throw ex;
}
}
public List<T> findByAttributteEquals(String atributo, Object valor) {
try{
tx = session.beginTransaction();
Criteria c = session.createCriteria(this.classe);
c.add(Restrictions.eq(atributo, valor));
return c.list();
}
catch(HibernateException ex){
tx.rollback();
throw ex;
}
}
public List<T> listByQuery(String query) {
try{
tx = session.beginTransaction();
return session.createQuery(query).list();
}
catch(HibernateException ex){
tx.rollback();
throw ex;
}
}
public void merge(T clazz) throws HibernateException {
try{
tx = session.beginTransaction();
session.merge(clazz);
tx.commit();
}
catch(HibernateException ex){
tx.rollback();
throw ex;
}
}
public List<T> listByNamedQuery(String namedQuery, String query) throws HibernateException {
try{
tx = session.beginTransaction();
return session.getNamedQuery(namedQuery).setString("desc", "%"+query+"%").list();
}
catch(HibernateException ex){
tx.rollback();
throw ex;
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package br.com.amazonas.sistecam.hibernate;
import br.com.caelum.vraptor.ioc.Component;
import br.com.caelum.vraptor.ioc.ComponentFactory;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
/**
*
* @author cassio
*/
@Component
public class CriadorSession implements ComponentFactory<Session> {
private SessionFactory factory;
public CriadorSession(SessionFactory factory){
this.factory = factory;
}
@Override
public Session getInstance() {
return factory.openSession();
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package br.com.amazonas.sistecam.hibernate;
import br.com.caelum.vraptor.ioc.Component;
import br.com.caelum.vraptor.ioc.ComponentFactory;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
/**
*
* @author Cássio Thadeu
*/
@Component
public class HibernateUtil implements ComponentFactory<SessionFactory> {
private static final SessionFactory sessionFactory = buildSessionFactory();
private static SessionFactory buildSessionFactory() {
try {
// Create the SessionFactory from hibernate.cfg.xml
return new Configuration().configure("br/com/amazonas/sistecam/hibernate/hibernate.cfg.xml").buildSessionFactory();
}
catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
@Override
public SessionFactory getInstance() {
return HibernateUtil.getSessionFactory();
}
}
@Resource
public class ClienteController {
private GenericDAO<Cliente> dao;
public ClienteController(GenericDAO<Cliente> dao) {
this.dao = dao;
}
public List<Cliente> lista(){
return dao.findAll();
}
}
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<table>
<thead>
<tr>
<td>
<th>Nome</th>
<th>Descrição</th>
</td>
</tr>
</thead>
<tbody>
<c:forEach items="${clienteList}" var="cliente">
<tr>
<td>cliente.razaoSocial</td>
<td>cliente.nomeFantasia</td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
HTTP Status 404 - /Vraptor/cliente/lista.jsptype Status report
message /Vraptor/cliente/lista.jsp
description The requested resource (/Vraptor/cliente/lista.jsp) is not available.
Apache Tomcat/7.0.11