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虾米 (左侧二维码扫一扫)欢迎添加!

org.hibernate.TransactionException: nested transactions not supported错误的解决方法讲解
你是第一个吃螃蟹的人
发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。