0

Estou subindo um projeto jsf, porem da este erro no console.

log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
org.hibernate.HibernateException: /hibernate.cfg.xml not found
  at org.hibernate.internal.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:173)
  at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:2093)
  at org.hibernate.cfg.Configuration.configure(Configuration.java:2074)
  at org.hibernate.cfg.Configuration.configure(Configuration.java:2054)
  at br.com.framework.hibernate.session.HibernateUtil.buildSessionFactory(HibernateUtil.java:40)
  at br.com.framework.hibernate.session.HibernateUtil.<clinit>(HibernateUtil.java:28)
  at br.com.project.filter.FilterOpenSessionInView.initFilterBean(FilterOpenSessionInView.java:40)
  at org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java:179)
  at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
  at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
  at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
  at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4950)
  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5652)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
  at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1015)
  at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:991)
  at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
  at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:712)
  at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:587)
  at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1815)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
  at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
  at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
  at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1506)
  at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:902)
  at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:361)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)









fev 14, 2018 11:35:25 PM org.apache.catalina.core.StandardContext filterStart
GRAVE: Exception starting filter conexaoFilter
java.lang.ExceptionInInitializerError: Erro ao criar conexão sessionFacotory
  at br.com.framework.hibernate.session.HibernateUtil.buildSessionFactory(HibernateUtil.java:47)
  at br.com.framework.hibernate.session.HibernateUtil.<clinit>(HibernateUtil.java:28)
  at br.com.project.filter.FilterOpenSessionInView.initFilterBean(FilterOpenSessionInView.java:40)
  at org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java:179)
  at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
  at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
  at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
  at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4950)
  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5652)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
  at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1015)
  at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:991)
  at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
  at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:712)
  at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:587)
  at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1815)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
  at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
  at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
  at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1506)
  at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:902)
  at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:361)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilter

1 Resposta 1

1

O arquivo de configuração XML Hibernate " hibernate.cfg.xml" sempre é colocado na raiz do seu classpath , fora de qualquer pacote. Se você colocar este arquivo de configuração em um diretório diferente, você pode encontrar o seguinte erro:

Initial SessionFactory creation failed.org.hibernate.HibernateException:
/hibernate.cfg.xml not found

Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.mkyong.persistence.HibernateUtil.buildSessionFactory(HibernateUtil.java:25)
    at com.mkyong.persistence.HibernateUtil.<clinit>(HibernateUtil.java:8)
    at com.mkyong.common.App.main(App.java:11)
Caused by: org.hibernate.HibernateException: /hibernate.cfg.xml not found
    at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
    at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1405)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1427)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
    at com.mkyong.persistence.HibernateUtil.buildSessionFactory(HibernateUtil.java:13)
    ... 2 more

ara pedir ao Hibernate procurar seu " hibernate.cfg.xml" arquivo em outro diretório, você pode modificar a SessionFactoryclasse de Hibernação padrão passando seu " hibernate.cfg.xml" caminho de arquivo.

    SessionFactory sessionFactory = new Configuration()
    .configure("/com/mkyong/persistence/hibernate.cfg.xml")
    .buildSessionFactory();

return sessionFactory;

Fonte: https://www.mkyong.com/hibernate/how-to-load-hibernate-cfg-xml-from-different-directory/

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .