I. Error creating bean with name 'hsfactory 'defined in class

Source: Internet
Author: User

[Java]
Org. springframework. beans. factory. beanCreationException: Error creating bean with name 'hsfactory 'defined in class path resource [schema. xml]: Invocation of init method failed; nested exception is org. hibernate. mappingException: entity class not found: User
At org. springframework. beans. factory. support. AbstractAutowireCapableBeanFactory. initializeBean (AbstractAutowireCapableBeanFactory. java: 1338)
At org. springframework. beans. factory. support. AbstractAutowireCapableBeanFactory. doCreateBean (AbstractAutowireCapableBeanFactory. java: 473)
At org. springframework. beans. factory. support. AbstractAutowireCapableBeanFactory $ 1.run( AbstractAutowireCapableBeanFactory. java: 409)
At java. security. AccessController. doPrivileged (Native Method)
At org. springframework. beans. factory. support. AbstractAutowireCapableBeanFactory. createBean (AbstractAutowireCapableBeanFactory. java: 380)
At org. springframework. beans. factory. support. AbstractBeanFactory $1. getObject (AbstractBeanFactory. java: 264)
At org. springframework. beans. factory. support. DefaultSingletonBeanRegistry. getSingleton (DefaultSingletonBeanRegistry. java: 222)
At org. springframework. beans. factory. support. AbstractBeanFactory. doGetBean (AbstractBeanFactory. java: 261)
At org. springframework. beans. factory. support. AbstractBeanFactory. getBean (AbstractBeanFactory. java: 185)
At org. springframework. beans. factory. support. AbstractBeanFactory. getBean (AbstractBeanFactory. java: 164)
At org. springframework. beans. factory. support. DefaultListableBeanFactory. preInstantiateSingletons (DefaultListableBeanFactory. java: 423)
At org. springframework. context. support. AbstractApplicationContext. finispolicanfactoryinitialization (AbstractApplicationContext. java: 728)
At org. springframework. context. support. AbstractApplicationContext. refresh (AbstractApplicationContext. java: 380)
At org. springframework. context. support. ClassPathXmlApplicationContext. <init> (ClassPathXmlApplicationContext. java: 139)
At org. springframework. context. support. ClassPathXmlApplicationContext. <init> (ClassPathXmlApplicationContext. java: 83)
At chentailei. test. TestHibernateDao. add (TestHibernateDao. java: 17)
At sun. reflect. NativeMethodAccessorImpl. invoke0 (Native Method)
At sun. reflect. NativeMethodAccessorImpl. invoke (NativeMethodAccessorImpl. java: 39)
At sun. reflect. DelegatingMethodAccessorImpl. invoke (DelegatingMethodAccessorImpl. java: 25)
At java. lang. reflect. Method. invoke (Method. java: 597)
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. InvokeMethod. evaluate (InvokeMethod. java: 20)
At org. junit. internal. runners. statements. RunBefores. evaluate (RunBefores. java: 28)
At org. junit. internal. runners. statements. RunAfters. evaluate (RunAfters. java: 31)
At org. junit. runners. BlockJUnit4ClassRunner. runChild (BlockJUnit4ClassRunner. java: 73)
At org. junit. runners. BlockJUnit4ClassRunner. runChild (BlockJUnit4ClassRunner. java: 46)
At org. junit. runners. ParentRunner. runChildren (ParentRunner. java: 180)
At org. junit. runners. ParentRunner. access $000 (ParentRunner. java: 41)
At org. junit. runners. ParentRunner $1. evaluate (ParentRunner. java: 173)
At org. junit. internal. runners. statements. RunBefores. evaluate (RunBefores. java: 28)
At org. junit. internal. runners. statements. RunAfters. evaluate (RunAfters. java: 31)
At org. junit. runners. ParentRunner. run (ParentRunner. java: 220)
At org. eclipse. jdt. internal. junit4.runner. JUnit4TestReference. run (JUnit4TestReference. java: 46)
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: org. hibernate. MappingException: entity class not found: User
At org. hibernate. mapping. PersistentClass. getMappedClass (PersistentClass. java: 99)
At org. hibernate. tuple. PropertyFactory. getGetter (PropertyFactory. java: 168)
At org. hibernate. tuple. PropertyFactory. buildIdentifierProperty (PropertyFactory. java: 44)
At org. hibernate. tuple. entity. EntityMetamodel. <init> (EntityMetamodel. java: 124)
At org. hibernate. persister. entity. AbstractEntityPersister. <init> (AbstractEntityPersister. java: 434)
At org. hibernate. persister. entity. SingleTableEntityPersister. <init> (SingleTableEntityPersister. java: 109)
At org. hibernate. persister. PersisterFactory. createClassPersister (PersisterFactory. java: 55)
At org. hibernate. impl. SessionFactoryImpl. <init> (SessionFactoryImpl. java: 226)
At org. hibernate. cfg. Configuration. buildSessionFactory (Configuration. java: 1300)
At org. springframework. orm. hibernate3.LocalSessionFactoryBean. newSessionFactory (LocalSessionFactoryBean. java: 814)
At org. springframework. orm. hibernate3.LocalSessionFactoryBean. buildSessionFactory (LocalSessionFactoryBean. java: 732)
At org. springframework. orm. hibernate3.AbstractSessionFactoryBean. afterPropertiesSet (AbstractSessionFactoryBean. java: 211)
At org. springframework. beans. factory. support. AbstractAutowireCapableBeanFactory. invokeInitMethods (AbstractAutowireCapableBeanFactory. java: 1369)
At org. springframework. beans. factory. support. AbstractAutowireCapableBeanFactory. initializeBean (AbstractAutowireCapableBeanFactory. java: 1335)
... 39 more
Caused by: java. lang. ClassNotFoundException: User
At java.net. URLClassLoader $ 1.run( URLClassLoader. java: 202)
At java. security. AccessController. doPrivileged (Native Method)
At java.net. URLClassLoader. findClass (URLClassLoader. java: 190)
At java. lang. ClassLoader. loadClass (ClassLoader. java: 306)
At sun. misc. Launcher $ AppClassLoader. loadClass (Launcher. java: 301)
At java. lang. ClassLoader. loadClass (ClassLoader. java: 247)
At java. lang. Class. forName0 (Native Method)
At java. lang. Class. forName (Class. java: 169)
At org. hibernate. util. ReflectHelper. classForName (ReflectHelper. java: 100)
At org. hibernate. mapping. PersistentClass. getMappedClass (PersistentClass. java: 96)
... 52 more
[Java]
Cause:
Due to the reverse generation of Hibernate ing files by DB Brower, The sprint-web project I created cannot be browsed. As a result, I used other hibernate-web projects to generate a User. hbm. xml ing file.
But the generated User. hbm. the xml class path is: <class name = "User" table = "d_user" catalog = "test">. The name points to xxx. entity. user,
So change to: xxx. entity. User exception solved!

 

Related Article

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.