首页 > 代码库 > hibernate4.2.4异常:Error parsing JNDI name [sessionFactory]
hibernate4.2.4异常:Error parsing JNDI name [sessionFactory]
org.hibernate.service.jndi.JndiException: Error parsing JNDI name [sessionFactory] at org.hibernate.service.jndi.internal.JndiServiceImpl.parseName(JndiServiceImpl.java:92) at org.hibernate.service.jndi.internal.JndiServiceImpl.bind(JndiServiceImpl.java:108) at org.hibernate.internal.SessionFactoryRegistry.addSessionFactory(SessionFactoryRegistry.java:89) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:480) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1790) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1861) at com.imooc.util.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:50) at com.imooc.util.HibernateSessionFactory.getCurrentSession(HibernateSessionFactory.java:33) at test.SellerTest.setUp(SellerTest.java:29) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: 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.service.jndi.internal.JndiServiceImpl.parseName(JndiServiceImpl.java:86) ... 32 more
以上异常是我在用eclipse-jee配置hibernate4是通过逆向工程创建了hibernate.cfg.xml文件,当创建了的xml文件中的<session-factory>元素多了一个name属性(也就是上面的name="SessionFactory"),就会报此错误,删除掉就行了!
本文出自 “IT菜鸟” 博客,请务必保留此出处http://mazongfei.blog.51cto.com/3174958/1895016
hibernate4.2.4异常:Error parsing JNDI name [sessionFactory]
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。