Error executing JSF project

Asked

Viewed 72 times

0

I am going up a jsf project, but give this error in the 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 answer

1


The Hibernate XML configuration file " hibernate.cfg.xml" is always placed at the root of your classpath , out of any package. If you put this configuration file in a different directory, you may encounter the following error:

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

to ask Hibernate to find his " hibernate.cfg.xml" file in another directory, you can modify the SessionFactoryclasse of Hibernation standard passing its " hibernate.cfg.xml" file path.

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

return sessionFactory;

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.