Hibernate exception: Error parsing JNDI name [XXX]

Source: Internet
Author: User


Beginner Hibernate, using the official log template to configure the log, run a small example,

Some exceptions are written in the log in the console:

21:16:36,036 debug entityloader:146 - static select for entity  cn.sjll.hibernate435.model.usermodel [optimistic_force_increment]: select usermodel0_.id  as id1_0_0_, usermodel0_.name as name2_0_0_, usermodel0_. age as age3_0_0_, usermodel0_. sex as sex4_0_0_ from users usermodel0_ where usermodel0_.id=?21:16:36,056  DEBUG Loader:56 - Static select for action ACTION_MERGE on  entity cn.sjll.hibernate435.model.usermodel: select usermodel0_.id as id1_0_0_,  usermodel0_.name as name2_0_0_, usermodel0_. age as age3_0_0_, usermodel0_. sex as sex4_0_0_ from users usermodel0_ where usermodel0_.id=?21:16:36,056  debug loader:56 - static select for action action_refresh on  entity cn.sjll.hibernate435.model.usermodel: select usermodel0_.id as id1_0_0_,  usermodel0_.name as name2_0_0_, usermodel0_. age as age3_0_0_, usermodel0_. sex as sex4_0_0_ from users usermodel0_ where usermodel0_.id=?21:16:36,056  debug sessionfactoryregistry:67 - initializing sessionfactoryregistry : [ email protected]21:16:36,066 debug sessionfactoryregistry:89 - registering  sessionfactory: 79e91a19-1980-411c-b450-bc0bb5f3abe0  () 21:16:36,066 debug  sessionfactoryregistry:100 - attempting to bind sessionfactory [] to  Jndi21:16:36,066  warn sessionfactoryregistry:116 - hhh000277: could not  bind factory to jndiorg.hibernate.engine.jndi.jndiexception: error parsing  jndi name []    at&Nbsp;org.hibernate.engine.jndi.internal.jndiserviceimpl.parsename (jndiserviceimpl.java:141)      at org.hibernate.engine.jndi.internal.jndiserviceimpl.bind (jndiserviceimpl.java:157)      at org.hibernate.internal.sessionfactoryregistry.addsessionfactory ( sessionfactoryregistry.java:103)     at org.hibernate.internal.SessionFactoryImpl.< Init> (sessionfactoryimpl.java:497)     at  Org.hibernate.cfg.Configuration.buildSessionFactory (configuration.java:1857)     at  Org.hibernate.cfg.Configuration.buildSessionFactory (configuration.java:1928)     at  Cn.sjll.hibernate435.util.HibernateUtil.buildSessionFactory (hibernateutil.java:11)     at  cn.sjll.hibernate435.util.HibernateUtil.<clinit> (Hibernateutil.java:7)     at  cn.sjll.hibernate435.util.testcrud.main (testcrud.java:15) 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 (namingmanager.java:662)     at  JAVAX.NAMING.INITIALCONTEXT.GETDEFAULTINITCTX (initialcontext.java:307)     at  JAVAX.NAMING.INITIALCONTEXT.GETURLORDEFAULTINITCTX (initialcontext.java:344)     at  Javax.naming.InitialContext.getNameParser (initialcontext.java:499)     at  Org.hibernate.engine.jndi.internal.JndiServiceImpl.parseName (jndiserviceimpl.java:135)      ...  8 more


Later found in my hibernate.cfg.xml in the Session-factory name= "",

Remove Name= "", and then run up, the log will not report the above information, write name= "SF" or other, but do not configure JNDI, the same will be reported above information, it appears session-factory optional attribute, if the name is written on the JNDI relationship.


Hereby record.

This article from "Rookie Stupid Fly" blog, please be sure to keep this source http://srteert.blog.51cto.com/4009782/1416439

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.