Olá;
Quanto eu executo a aplicação aparece o seguinte erro
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: Cannot open connection
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
root cause
org.hibernate.exception.JDBCConnectionException: Cannot open connection
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354)
projeto.util.HibernateUtil.getSession(HibernateUtil.java:20)
projeto.dao.SuperDAO.getSession(SuperDAO.java:19)
projeto.dao.SuperDAO.getListaObjeto(SuperDAO.java:67)
projeto.dao.UsuarioDAO.getListaUsuario(UsuarioDAO.java:31)
projeto.faces.UsuarioFace.getListaUsuario(UsuarioFace.java:43)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
javax.el.BeanELResolver.getValue(BeanELResolver.java:87)
com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
org.apache.el.parser.AstValue.getValue(AstValue.java:169)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
org.richfaces.component.UISequence.getValue(UISequence.java:178)
org.richfaces.component.UISequence.createExtendedDataModel(UISequence.java:112)
org.richfaces.component.UIDataTableBase.createExtendedDataModel(UIDataTableBase.java:195)
org.richfaces.component.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:467)
org.richfaces.component.UIDataAdaptor.setRowKey(UIDataAdaptor.java:278)
org.richfaces.renderkit.AbstractTableRenderer.encodeTableFacets(AbstractTableRenderer.java:118)
org.richfaces.renderkit.DataTableRenderer.doEncodeBegin(DataTableRenderer.java:303)
org.richfaces.renderkit.RendererBase.encodeBegin(RendererBase.java:115)
javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:820)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1755)
javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:401)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
root cause
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/projeto_2011
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354)
projeto.util.HibernateUtil.getSession(HibernateUtil.java:20)
projeto.dao.SuperDAO.getSession(SuperDAO.java:19)
projeto.dao.SuperDAO.getListaObjeto(SuperDAO.java:67)
projeto.dao.UsuarioDAO.getListaUsuario(UsuarioDAO.java:31)
projeto.faces.UsuarioFace.getListaUsuario(UsuarioFace.java:43)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
javax.el.BeanELResolver.getValue(BeanELResolver.java:87)
com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
org.apache.el.parser.AstValue.getValue(AstValue.java:169)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
org.richfaces.component.UISequence.getValue(UISequence.java:178)
org.richfaces.component.UISequence.createExtendedDataModel(UISequence.java:112)
org.richfaces.component.UIDataTableBase.createExtendedDataModel(UIDataTableBase.java:195)
org.richfaces.component.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:467)
org.richfaces.component.UIDataAdaptor.setRowKey(UIDataAdaptor.java:278)
org.richfaces.renderkit.AbstractTableRenderer.encodeTableFacets(AbstractTableRenderer.java:118)
org.richfaces.renderkit.DataTableRenderer.doEncodeBegin(DataTableRenderer.java:303)
org.richfaces.renderkit.RendererBase.encodeBegin(RendererBase.java:115)
javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:820)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1755)
javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:401)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.22 logs.
Eu procurei nos tópicos e achei que o erro é causado por não encontrar o .jar do driver de conexão com o MySQL.
Porém, eu já coloquei o .jar na pasta lib do projeto bem como adicionei na CLASSPATH e o erro persiste.
Aqui embaixo tem a classe do Hibernate
package projeto.util;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
public class HibernateUtil {
//Variável privada para ser usada no Singleton
private static HibernateUtil hbm;
private SessionFactory sessionFactory;
//Implementação do Singleton
public static HibernateUtil getInstance(){
if (hbm == null){
hbm = new HibernateUtil();
}
return hbm;
}
//Retorno da Seção
public Session getSession(){
Session retorno = sessionFactory.openSession();
retorno.beginTransaction();
return retorno;
}
//Construtor da Classe
private HibernateUtil(){
sessionFactory = new AnnotationConfiguration()
.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect")//Dialeto de comunicação
.setProperty("hibernate.connection.driver-class", "com.mysql.jdbc.Driver")//cliente JDBC
.setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/projeto_2011")//URL de conexão com o banco de dados
.setProperty("hibernate.connection.username", "root")//Usuário
.setProperty("hibernate.connection.password", "longlife")//Senha
.setProperty("hibernate.hbm2ddl.auto", "update")//Injeção automática de esquema
.setProperty("hibernate.show_sql", "true")//Mostrar Sql
.setProperty("hibernate.format_sql", "true")
.setProperty("hibernate.c3p0.acquire_increment", "1")//Características do Pool de Conexões
.setProperty("hibernate.c3p0.idle_test_period", "100")
.setProperty("hibernate.c3p0.max_size", "10")
.setProperty("hibernate.c3p0.max_statements", "0")
.setProperty("hibernate.c3p0.min_size", "5")
.setProperty("hibernate.c3p0.timeout", "100")
.addAnnotatedClass(projeto.util.Teste.class)
.addAnnotatedClass(projeto.entity.Usuario.class)
.addAnnotatedClass(projeto.entity.Evento.class)
.addAnnotatedClass(projeto.entity.Reserva.class)
.addAnnotatedClass(projeto.entity.Equipamento.class)
.addAnnotatedClass(projeto.entity.Categoria.class)
.buildSessionFactory();
}
}
Grato pela ajuda.