Caused by: org.hibernate.MappingException: Association references unmapped class

2011-8-25 18:40:16 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Program Files\Java\jdk1.6.0_01\bin;D:\Program Files\Apache Software Foundation\Tomcat 6.0\bin
2011-8-25 18:40:16 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2011-8-25 18:40:16 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 790 ms
2011-8-25 18:40:16 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2011-8-25 18:40:16 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.18
2011-8-25 18:40:21 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
2011-8-25 18:40:26 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: News
Caused by: org.hibernate.MappingException: Association references unmapped class: News
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2377)
at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2659)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1149)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1305)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1203)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:285)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2011-8-25 18:40:26 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2011-8-25 18:40:26 org.apache.catalina.core.StandardContext start
严重: Context [/sato] startup failed due to previous errors
2011-8-25 18:40:26 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2011-8-25 18:40:27 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2011-8-25 18:40:27 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2011-8-25 18:40:27 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/64  config=null
2011-8-25 18:40:27 org.apache.catalina.startup.Catalina start
信息: Server startup in 11090 ms

老是出现这个问题  不是News的映射文件无法映射 就是其他的   不知道什么原因,  我看了名字和路径都没写错  是什么问题啊   跪求答案

APPLICATIONCONTEXT.XML
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/mytest" />
<property name="username" value="root" />
<property name="password" value="root" />
<property name="maxWait" value="500" />
<property name="maxActive" value="100" />
<property name="maxIdle" value="30" />
<property name="defaultAutoCommit" value="true" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hivernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/test/beans/Advertisement.hbm.xml</value>
<value>com/test/beans/Advise.hbm.xml</value>
<value>com/test/beans/Diary.hbm.xml</value>
<value>com/test/beans/MyLog.hbm.xml</value>
<value>com/test/beans/News.hbm.xml</value>
<value>com/test/beans/NewsBoard.hbm.xml</value>
<value>com/test/beans/Reply.hbm.xml</value>
<value>com/test/beans/Theme.hbm.xml</value>
<value>com/test/beans/ThemeBoard.hbm.xml</value>
<value>com/test/beans/TheUser.hbm.xml</value>
<value>com/test/beans/UserToUser.hbm.xml</value>
</list>
</property>
</bean>

<bean id="userToUserDAOImpl" class="com.test.dao.impl.UserToUserDAOImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>

<bean id="test" class="com.test.actions.TestAction">
<property name="userToUserDAOImpl" ref="userToUserDAOImpl"></property>
</bean>
</beans>

展示一个映射文件吧

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="com.test.beans.News" table="t_news" catalog="sato">
        <id name="id" type="java.lang.Integer">
            <column name="id" />
            <generator class="native"></generator>
        </id>
        <many-to-one name="newsBoard" class="com.test.beans.NewsBoard" fetch="select">
            <column name="type" not-null="true">
                <comment>所属新闻板块</comment>
            </column>
        </many-to-one>
        <many-to-one name="theUser" class="com.test.beans.TheUser" fetch="select">
            <column name="editor" not-null="true">
                <comment>作者</comment>
            </column>
        </many-to-one>
        <property name="title" type="java.lang.String">
            <column name="title" length="45" not-null="true">
                <comment>标题</comment>
            </column>
        </property>
        <property name="content" type="java.lang.String">
            <column name="content" length="3000" not-null="true">
                <comment>内容</comment>
            </column>
        </property>
        <property name="date" type="java.lang.String">
            <column name="date" length="45" not-null="true">
                <comment>时间</comment>
            </column>
        </property>
    </class>
</hibernate-mapping>

你可能感兴趣的:(Web)