IT源码网

Could not bind factory to JNDI 解决方法

sanshao 2021年04月03日 程序员 379 0

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 net.sf.hibernate.util.NamingHelper.bind(NamingHelper.java:52)

   at net.sf.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)

   at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:172)

   at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:796)

   at TestMain.main(TestMain.java:22)

 

在hibernate.cfg.xml中session-factory设置了name属性,hibernate会试图把这个sessionfacotry注册到jndi中去

将name属性去掉即可解决

评论关闭
IT源码网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!