问题描述
本人手工在com/anndy/pojos/oracle/路径下添加了Sp.hbm.xml文件,并在数据库中新建了对应的表,并在applicationContext.xml文件中添加了相应的语句<value>com/anndy/pojos/oracle/Sp.hbm.xml</value>,然后再启动Tomcat时提示如下错误,请问有什么解决办法没有啊。Causedby:java.io.FileNotFoundException:classpathresource[com/anndy/pojos/oracle/Sp.hbm.xml]cannotbeopenedbecauseitdoesnotexist
解决方案
解决方案二:
hbm文件在com/anndy/pojos/oracle下?<value>classpath:/x/Sp.hbm.xml</value>
解决方案三:
按楼上说的就可以了如果一次性指定所有的映射文件<propertyname="mappingLocations"value="classpath:com/anndy/pojos/oracle/*.hbm.xml"/>
解决方案四:
Sp.hbm.xml文件是在com/anndy/pojos/oracle下,但是还是有这样的错误,我把Tomcat提示的错误贴出来78[main]INFOorg.hibernate.cfg.Environment-Hibernate3.3.0.SP194[main]INFOorg.hibernate.cfg.Environment-hibernate.propertiesnotfound94[main]INFOorg.hibernate.cfg.Environment-Bytecodeprovidername:javassist110[main]INFOorg.hibernate.cfg.Environment-usingJDK1.4java.sql.Timestamphandling547[main]INFOorg.hibernate.cfg.HbmBinder-Mappingclass:com.anndy.pojos.Zhuanyetype->zhuanyetype610[main]INFOorg.hibernate.cfg.HbmBinder-Mappingclass:com.anndy.pojos.Biaozhuntype->biaozhuntype625[main]INFOorg.hibernate.cfg.HbmBinder-Mappingclass:com.anndy.pojos.Gtbztopic->gtbztopic797[main]INFOorg.hibernate.cfg.HbmBinder-Mappingclass:com.anndy.pojos.Gtbzgzxs->gtbzgzxs797[main]INFOorg.hibernate.cfg.HbmBinder-Mappingclass:com.anndy.pojos.Gtbzxx->gtbzxx797[main]INFOorg.hibernate.cfg.HbmBinder-Mappingcollection:com.anndy.pojos.Gtbzxx.yszls->bzxx_yszl797[main]INFOorg.hibernate.cfg.HbmBinder-Mappingcollection:com.anndy.pojos.Gtbzxx.refusers->user_refbzxx813[main]INFOorg.hibernate.cfg.HbmBinder-Mappingclass:com.anndy.pojos.Gtbzzw->gtbzzws875[main]INFOorg.hibernate.cfg.HbmBinder-Mappingclass:com.anndy.pojos.Gtbzthumb->gtbzthumb875[main]INFOorg.hibernate.cfg.HbmBinder-Mappingclass:com.anndy.pojos.Gtbzfj->gtbzfjs891[main]INFOorg.hibernate.cfg.HbmBinder-Mappingclass:com.anndy.pojos.Publevel->publevel907[main]INFOorg.hibernate.cfg.HbmBinder-Mappingclass:com.anndy.pojos.Yszlfj->yszlfj907[main]INFOorg.hibernate.cfg.HbmBinder-Mappingclass:com.anndy.pojos.Yszl->yszl922[main]INFOorg.hibernate.cfg.HbmBinder-Mappingclass:com.anndy.pojos.KeJian->kejian2010-11-1617:09:57org.apache.catalina.core.StandardContextlistenerStart严重:Exceptionsendingcontextinitializedeventtolistenerinstanceofclassorg.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'sessionFactory'definedinServletContextresource[/WEB-INF/classes/com/anndy/config/spring/applicationContext.xml]:Invocationofinitmethodfailed;nestedexceptionisjava.io.FileNotFoundException:classpathresource[com/anndy/pojos/oracle/Sp.hbm.xml]cannotbeopenedbecauseitdoesnotexistatorg.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:4350)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:924)atorg.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:887)atorg.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)atorg.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)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(NativeMethodAccessorImpl.java:39)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)atjava.lang.reflect.Method.invoke(Method.java:597)atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)Causedby:java.io.FileNotFoundException:classpathresource[com/anndy/pojos/oracle/Sp.hbm.xml]cannotbeopenedbecauseitdoesnotexistatorg.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:142)atorg.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:631)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)...39more
解决方案五:
前面的hbm.xml文件加载的都很正常,就是在Sp.hbm.xml时出错。
解决方案六:
来学习...
解决方案七:
你手动添加到项目里还是添加到部署的目录中?看看你部署的路径下面这个文件夹中有这个文件否...
解决方案八:
ckeditor
解决方案九:
楼上有正解
解决方案十:
是不是sp.hbm.xml里面有属性是需要到别的表的相应.hbm.xml文件?
解决方案十一:
引用9楼xjlong555的回复:
是不是sp.hbm.xml里面有属性是需要到别的表的相应.hbm.xml文件?
个人感觉是不是LZ把文件名与在Spring中配置的映射文件的名称写错了啊,比如大小写啊或是其他的。。。建议仔细看看,因为错误很明显,说找不到文件!
解决方案十二:
来学习一下!我也很好奇是什么原因!
解决方案十三:
查看你的.xml文件存放在位置需要和你的java文件存在同一目录下
解决方案十四:
学习了。。。。。