hibernate4.2.4异常:Error parsing JNDI name [sessionFactory]

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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]的主要内容,如果未能解决你的问题,请参考以下文章

mac下的mysql问题:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using pa

mac mysql连接报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using pa

Linux 文件系统引起的云盘文件系统异常导致 MySQL 数据页损坏事故恢复复盘

Jquery ajax get request to aspx web method not hit the breakpoint in the method and error is json pa

失败:语义异常 [错误 10014]:第 1:21 行错误的参数“stock_price_high”:

在error日志打印异常