Galera a questão e a seguinte eu estou tentando fazer um aplicação teste aqui Struts com hibernate só que esta gerando um erro na hora de rodar.
Esse erro no bronser:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoClassDefFoundError: org/hibernate/Session
br.com.caelum.struts.action.AdicionaContatoAction.execute(AdicionaContatoAction.java:24)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.ClassNotFoundException: org.hibernate.Session
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
java.lang.ClassLoader.loadClassInternal(Unknown Source)
br.com.caelum.struts.action.AdicionaContatoAction.execute(AdicionaContatoAction.java:24)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.
import br.com.caelum.struts.form.ContatoForm;
public class AdicionaContatoAction extends Action {
public ActionForward execute(ActionMapping map, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException, SystemException{
Session session = new HibernateFactory().getSession();
org.hibernate.Transaction transaction = session.beginTransaction(); //Iniciando uma transação
// adiciona ao banco de dados
ContatoDAO dao = new ContatoDAO(session);
// log
System.out.println("Tentando criar um novo contato...");
// formulário de cliente
ContatoForm formulario = ((ContatoForm) form);
// acessa o bean
Contato contato = formulario.getContato();
// adiciona ao banco de dados
dao.salva(contato);
// ok.... visualização
return map.findForward("ok");
}
}
package br.com.caelum.struts.action;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
public class HibernateFactory {
private static SessionFactory factory;
static {
AnnotationConfiguration cfg = new AnnotationConfiguration();
cfg.addAnnotatedClass(Contato.class);
factory = cfg.buildSessionFactory();
}
public static Session getSession() {
return factory.openSession();
}
}
e aqui esta o meu arquivo hibernate.properties
hibernate.dialect org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql://localhost:3306/contato
hibernate.connection.username root
hibernate.connection.password
Desde de já eu agradeço pela ajuda.