服务启动时log4j提醒Could not bind factory to JNDI

服务启动时log4j提示Could not bind factory to JNDI

服务启动时log4j提示

WARN SessionFactoryObjectFactory:121 - 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

原因:hibernate.cfg.xml文件配置<session-factory name="foo">,

因为有了name属性的配置,hibernate会试图把这个sessionfacotry注册到jndi中去,导致出现上述错误


解决方法:删掉name配置,仅保留<session-factory>