问题描述
org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'sessionFactory'definedinServletContextresource[/WEB-INF/applicationContext.xml]:Invocationofinitmethodfailed;nestedexceptionisorg.hibernate.MappingException:Associationreferencesunmappedclass:com.smscenter.model.content.MessageSendatorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1337)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)atjava.security.AccessController.doPrivileged(NativeMethod)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)atorg.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)atorg.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)atorg.apache.catalina.core.StandardContext.start(StandardContext.java:4342)atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)atorg.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)atorg.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)atorg.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)atorg.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)atorg.apache.catalina.core.StandardHost.start(StandardHost.java:719)atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)atorg.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)atorg.apache.catalina.core.StandardService.start(StandardService.java:516)atorg.apache.catalina.core.StandardServer.start(StandardServer.java:710)atorg.apache.catalina.startup.Catalina.start(Catalina.java:578)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)Causedby:org.hibernate.MappingException:Associationreferencesunmappedclass:com.smscenter.model.content.MessageSendatorg.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2370)atorg.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2652)atorg.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)atorg.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)atorg.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)atorg.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:673)atorg.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)...39more2011-3-309:52:22org.apache.catalina.core.StandardContextlistenerStart严重:Exceptionsendingcontextinitializedeventtolistenerinstanceofclassorg.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'sessionFactory'definedinServletContextresource[/WEB-INF/applicationContext.xml]:Invocationofinitmethodfailed;nestedexceptionisorg.hibernate.MappingException:Associationreferencesunmappedclass:com.smscenter.model.content.MessageSendatorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1337)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)atjava.security.AccessController.doPrivileged(NativeMethod)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)atorg.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)atorg.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)atorg.apache.catalina.core.StandardContext.start(StandardContext.java:4342)atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)atorg.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)atorg.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)atorg.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)atorg.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)atorg.apache.catalina.core.StandardHost.start(StandardHost.java:719)atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)atorg.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)atorg.apache.catalina.core.StandardService.start(StandardService.java:516)atorg.apache.catalina.core.StandardServer.start(StandardServer.java:710)atorg.apache.catalina.startup.Catalina.start(Catalina.java:578)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
解决方案
解决方案二:
nestedexceptionisorg.hibernate.MappingException:Associationreferencesunmappedclass:com.smscenter.model.content.MessageSend
解决方案三:
可是我有这个配置文件啊
解决方案四:
配置文件贴出来
解决方案五:
<?xmlversion="1.0"encoding="utf-8"?><!DOCTYPEhibernate-mappingPUBLIC"-//Hibernate/HibernateMappingDTD3.0//EN""http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><hibernate-mapping><classname="com.sms.model.content.MessageSend"table="SMS_MESSAGE_SEND"><idname="id"type="java.lang.Long"><columnname="ID"/><generatorclass="identity"/></id><propertyname="userPhoneNum"type="java.lang.String"><columnname="USER_PHONE_NUM"length="100"><comment>用户号码</comment></column></property><propertyname="msgContent"type="java.lang.String"><columnname="MSG_CONTENT"length="1000"><comment>短信内容</comment></column></property><propertyname="msgLength"type="java.lang.Integer"><columnname="MSG_LENGTH"><comment>短信长度</comment></column></property><propertyname="smsNum"type="java.lang.Integer"><columnname="SMS_NUM"><comment>短信拆分总条数</comment></column></property><propertyname="checkStatus"type="java.lang.Integer"><columnname="CHECK_STATUS"><comment>状态:0:未审1:已审2:不审3:失败</comment></column></property><propertyname="isSend"type="java.lang.Integer"><columnname="IS_SEND"><comment>发送状态:0:未发送1:已发送</comment></column></property><propertyname="numPart"type="java.lang.Integer"><columnname="NUM_PART"><comment>运营商:1:移动2:电信3:联通4:小灵通</comment></column></property><propertyname="sendDate"type="java.util.Date"><columnname="SEND_DATE"><comment>发送时间</comment></column></property><propertyname="createDate"type="java.util.Date"><columnname="CREATE_DATE"><comment>创建时间</comment></column></property><propertyname="checkDate"type="java.util.Date"><columnname="CHECK_DATE"><comment>审核时间</comment></column></property><!--审核人--><many-to-onename="checker"class="com.sms.model.admin.Manager"column="CHECKER"lazy="false"/><!--客户--><many-to-onename="manager"class="com.sms.model.admin.Manager"column="USER_ID"lazy="false"/></class></hibernate-mapping>
解决方案六:
有哪位好心人帮帮忙啊谢谢你们了哈
解决方案七:
com.smscenter.model.content.MessageSend(报错信息)com.sms.model.content.MessageSend(配置文件)你确定没错?
解决方案八:
没有啊我现在什么也看不出来了。眼晕了
解决方案九:
哪位高手出手相助一下。本人很急。等着急用,谢谢了啊