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.initialat 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
The above exception is what I am configuring with Eclipse-jee hibernate4 is a hibernate.cfg.xml file created by reverse engineering, when the <session-factory> element in the created XML file has more than one name attribute (That is, the above name= "Sessionfactory"), will report this error, delete it!
This article is from the "It Rookie" blog, make sure to keep this source http://mazongfei.blog.51cto.com/3174958/1895016
hibernate4.2.4 exception: Error parsing JNDI name [Sessionfactory]