Invocation of Init method failed; Nested exception is org.hibernate.MappingException

Source: Internet
Author: User
Org.springframework.beans.factory.BeanCreationException:Error creating Bean with Name ' sessionfactory ' defined in file [C:\Users\smart\Workspaces\MyEclipse 10\bsshopping\webroot\web-inf\classes\applicationcontext-bean.xml]: Invocation of Init method failed; Nested exception is Org.hibernate.MappingException:An Annotationconfiguration instance are required to use <mapping CLA Ss= ""/>
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean ( abstractautowirecapablebeanfactory.java:1455)
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean ( abstractautowirecapablebeanfactory.java:519)
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:456)
At Org.springframework.beans.factory.support.abstractbeanfactory$1.getobject (abstractbeanfactory.java:294)
At Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:225)
At Org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (abstractbeanfactory.java:291)
At Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:193)
At Org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons ( defaultlistablebeanfactory.java:591)
At Org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization ( abstractapplicationcontext.java:918)
At Org.springframework.context.support.AbstractApplicationContext.refresh (abstractapplicationcontext.java:469)
At Org.springframework.context.support.classpathxmlapplicationcontext.<init> ( classpathxmlapplicationcontext.java:139)
At Org.springframework.context.support.classpathxmlapplicationcontext.<init> ( CLASSPATHXMLAPPLICATIONCONTEXT.JAVA:83)
At Com.bsshops.test.UserServiceImplTest.setUpBeforeClass (userserviceimpltest.java:16)
At Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
At Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:57)
At Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:43)
At Java.lang.reflect.Method.invoke (method.java:606)
At Org.junit.internal.runners.ClassRoadie.runBefores (classroadie.java:49)
At org.junit.internal.runners.ClassRoadie.runProtected (classroadie.java:36)
At Org.junit.internal.runners.JUnit4ClassRunner.run (junit4classrunner.java:42)
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:org.hibernate.MappingException:An annotationconfiguration instance is required-use <mapping class= "com. Bsshops.domin.City "/>
At Org.hibernate.cfg.Configuration.parseMappingElement (configuration.java:1600)
At Org.hibernate.cfg.Configuration.parseSessionFactory (configuration.java:1555)
At Org.hibernate.cfg.Configuration.doConfigure (configuration.java:1534)
At Org.hibernate.cfg.Configuration.doConfigure (configuration.java:1508)
At Org.hibernate.cfg.Configuration.configure (configuration.java:1443)
At Org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory (Localsessionfactorybean.java : 642)
At Org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet ( abstractsessionfactorybean.java:188)
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods ( abstractautowirecapablebeanfactory.java:1514)
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean ( abstractautowirecapablebeanfactory.java:1452)
... More


Java.lang.NullPointerException
At Com.bsshops.test. Teardownafterclass (
At Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
At Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:57)
At Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:43)
At Java.lang.reflect.Method.invoke (method.java:606)
At Org.junit.internal.runners.ClassRoadie.runAfters (classroadie.java:65)
At org.junit.internal.runners.ClassRoadie.runProtected (classroadie.java:40)
At Org.junit.internal.runners.JUnit4ClassRunner.run (junit4classrunner.java:42)
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)

Exception information: Org.hibernate.MappingException:An Annotationconfiguration instance is required to use <mapping class= "* * *"/& Gt Cause Analysis:

Hibernate configuration file, if you have <mapping class= "Com.jjj.Student"/>, then the annotation method is used to describe the mapping class. When initializing configuation, you should use Annoationconfiguration, the code is as follows:

Configuration cfg = new annoationconfiguration ();
Sessionfactory SF = Cfg.configure (). Buildsessionfactory ();

If, when you are mapping, you are not using annotation, use the configuration.

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.