MappingException:未知实体

时间:2013-04-28 06:49:02

标签: java hibernate maven spring-mvc

使用Spring,Maven,Hibernate,MVC项目。在构建项目并安装依赖项之后,我遇到了这个异常。这看起来很奇怪。所有测试单元都已成功,并且没有指示数据库配置不正确。

在Tomcat7 JRE 1.7中使用ojdbc6驱动程序。那有什么问题?

注意:代码本身没有问题。因为它和我的朋友一起工作得很好。所以不要告诉我改变与类或模型相关的东西。该项目已经过全面测试。这似乎是一个奇怪的问题。

Apr 28, 2013 10:40:56 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class    com.nortal.web.listener.VersionListener
org.hibernate.MappingException: Unknown entity: com.me.personal.model.metadata.SchemaInfo
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:691)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:92)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:1005)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:998)
at com.nortal.persistence.hibernate.dao.HibernateGenericDao.getById(HibernateGenericDao.java:90)
at com.nortal.service.impl.GenericServiceImpl.getById(GenericServiceImpl.java:39)
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:601)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at sun.proxy.$Proxy19.getById(Unknown Source)
at com.nortal.web.listener.VersionListener.obtainSchemaVersion(VersionListener.java:88)
at com.nortal.web.listener.VersionListener.contextInitialized(VersionListener.java:32)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:655)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1628)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)

* .xml.hbm文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.me.personal.metadata">
<class name="SchemaInfo" table="schema_info">
    <id name="id" type="long" column="id" />
    <property name="version" column="schema_version" type="integer" />
</class>

1 个答案:

答案 0 :(得分:1)

您已将hibernate XML文件定义为*xml.hbm。这是不正确的,因为hibernate映射文件以*hbm.xml结尾。解决之后,您可能会发现Spring可以加载POJO的映射文件。