529 [main] WARN org.hibernate.impl.SessionFactoryObjectFactory - Could not bind factory to JNDI
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getNameParser(Unknown Source)
at org.hibernate.util.NamingHelper.bind(NamingHelper.java:75)
at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:113)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:348)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
at com.java.hibernate.connection.HibernateUtil.<clinit>(HibernateUtil.java:14)
at c.java.hibernate.connection.mainText.main(mainText.java:14)


Solution:
 
  This problem is caused by that Hibernate can't bind the factory to JNDI, but binding the factory to JNDI is only for a hibernate application which is deployed on a EJB-container.
  Thus, we need to get rid of a name of the factory in your configuration file (hibernate.cfg.xml) as well as this quote(""). You can see the configuration file like <session-factory>


Ref: https://forum.hibernate.org/viewtopic.php?p=2441498

 

Posted by 김뭍은 유학생
,