java.lang.IllegalStateException: Could not locate SessionFactory in JNDI
问题 Good evening, i get the above exception when using Hibernate with JSF, i saw it many times in the past and the root cause was that like this <session-factory name="sessionFactory"> so i removed the name and change the generated code for creating the SessionFactory from that: protected SessionFactory getSessionFactory() { try { return (SessionFactory) new InitialContext() .lookup("SessionFactory"); } catch (Exception e) { log.error("Could not locate SessionFactory in JNDI", e); throw new