我在做 spring 那个配置的时候发生了如错误:帮忙看一下,谢谢 
  
log4j:ERROR Could not find value for key log4j.appender.warn
log4j:ERROR Could not instantiate appender named "warn".
13:43:18,968  INFO CollectionFactory:71 - Commons Collections 3.x available
13:43:19,015  INFO XmlBeanDefinitionReader:163 - Loading XML bean definitions from URL [file:/F:/hibernate/yyspringtest/bin/properties.xml]
13:43:19,375  INFO ClassPathXmlApplicationContext:92 - Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=5963049]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,sessionFactory,transactionManager,user,addressDao]; root of BeanFactory hierarchy
13:43:19,390  INFO ClassPathXmlApplicationContext:290 - 5 beans defined in application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=5963049]
13:43:19,406  INFO ClassPathXmlApplicationContext:432 - Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@e3b895]
13:43:19,406  INFO ClassPathXmlApplicationContext:454 - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@5e3974]
13:43:19,406  INFO DefaultListableBeanFactory:268 - Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,sessionFactory,transactionManager,user,addressDao]; root of BeanFactory hierarchy]
13:43:19,468  INFO DriverManagerDataSource:155 - Loaded JDBC driver: org.gjt.mm.mysql.Driver
13:43:19,515  INFO Environment:500 - Hibernate 3.2.0
13:43:19,531  INFO Environment:533 - hibernate.properties not found
13:43:19,531  INFO Environment:667 - Bytecode provider name : cglib
13:43:19,531  INFO Environment:584 - using JDK 1.4 java.sql.Timestamp handling
13:43:19,718 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(2) Document is invalid: no grammar found.
13:43:19,718 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(2) Document root element "hibernate-mapping", must match DOCTYPE root "null".
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [file:/F:/hibernate/yyspringtest/bin/properties.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: invalid mapping
13:43:19,750  INFO DefaultListableBeanFactory:555 - Destroying singletons in factory {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,sessionFactory,transactionManager,user,addressDao]; root of BeanFactory hierarchy}
org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:463)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:679)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1091)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:396)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:87)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:72)
at org.appfuse.dao.testhibernate.TestAddress.run(TestAddress.java:26)
at org.appfuse.dao.testhibernate.TestAddress.main(TestAddress.java:13)
Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:460)
... 11 more <bean id="addressDao" class="org.appfuse.dao.testhibernate.TestaddressIntanceImpl"> 
  <property name="sessionFactory"> 
            <ref local="sessionFactory"/> 
        </property>     </bean>  
    
     <property name="mappingResources">
<list>
  <value>customer.hbm.xml</value>
</list>
</property>


<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping package="org.appfuse.dao.testhibernate" >
<class name ="Customer" table ="customer">
<id name="customerid"  type="java.lang.Long" >
<generator class="increment"/>
</id>
<property name="firstname" column="firstname"></property>
<property name="lastname" column="lastname"></property>
<set name="address">
<key column="customer"/>
<one-to-many class ="org.appfuse.dao.testhibernate.CustomerAddress"></one-to-many>
</set>
</class>
<class name="CustomerAddress" table="customerAddress">
<id name="customerAddressid"   type="java.lang.Long" >
<generator class="increment"/>
</id>
<property name="customer" column="customer"/>
<property name="line1" column="line1"/>
<property name="line2" column="line2"/>
<property name="line3" column="line3"/>
<property name="postcode" column="postcode"/>
</class>
</hibernate-mapping>

解决方案 »

  1.   

    貌似是log4j的配置文件出错。..
      

  2.   

    org.hibernate.MappingException: invalid mapping 是hibernate映射的配置文件解析错误
      

  3.   

    [file:/F:/hibernate/yyspringtest/bin/properties.xml
     如果你不会配置log4j的配置文件  就在上边得那个路径里直接删了。 就可以启动了
      

  4.   

    其实这个和log4j 没有关系 ,是hibernate的配置错误了,小宋 能具体说一下哪个文件配置错误了 谢谢
      

  5.   

    properties.xml  这个文件错了。。
      

  6.   

    不好意思刚才误导了。 hibernate映射文件错误。<?xml version="1.0" encoding="UTF-8"?> 
    <hibernate-mapping package="org.appfuse.dao.testhibernate" > 
    <class name ="Customer" table ="customer"> 
    <id name="customerid"  type="java.lang.Long" > 
    <generator class="increment"/> 
    </id> 
    <property name="firstname" column="firstname"> </property> 
    <property name="lastname" column="lastname"> </property> 
    <set name="address"> 
    <key column="customer"/> 
    <one-to-many class ="org.appfuse.dao.testhibernate.CustomerAddress"> </one-to-many> 
    </set> 
    </class> 
    </hibernate-mapping>
    <hibernate-mapping>
    <class name="CustomerAddress" table="customerAddress"> 
    <id name="customerAddressid"   type="java.lang.Long" > 
    <generator class="increment"/> 
    </id> 
    <property name="customer" column="customer"/> 
    <property name="line1" column="line1"/> 
    <property name="line2" column="line2"/> 
    <property name="line3" column="line3"/> 
    <property name="postcode" column="postcode"/> 
    </class> 
    </hibernate-mapping>分开成两个文件看看行不行。 <property name="mappingResources"> 
    <list> 
      <value>customer.hbm.xml </value> 
     <value>CustomerAddress.hbm.xml </value> </list> 
    </property> 
      

  7.   

    <class name="CustomerAddress" table="customerAddress"> 
    <class name ="Customer" table ="customer"> 
    name 都是要带包名的.
    看你是不 是忘记了加包名 .CustomerAddress,Customer 这两个类应该不是在缺省包下面把.
      

  8.   

    我的完整的配置是: 错误还是最前面的错误 <?xml version="1.0" encoding="UTF-8"?>
    <hibernate-mapping package="org.appfuse.dao.testhibernate" >
    <class name ="Customer" table ="customer">
    <id name="customerid"  type="java.lang.Long" >
    <generator class="increment"/>
    </id>
    <property name="firstname" column="firstname"></property>
    <property name="lastname" column="lastname"></property>
    <set name="address">
    <key column="customer"/>
    <one-to-many class ="org.appfuse.dao.testhibernate.CustomerAddress"></one-to-many>
    </set>
    </class>


    <class name="CustomerAddress" table="customerAddress">
    <id name="customerAddressid"   type="java.lang.Long" >
    <generator class="increment"/>
    </id>
    <property name="customer" column="customer"/>
    <property name="line1" column="line1"/>
    <property name="line2" column="line2"/>
    <property name="line3" column="line3"/>
    <property name="postcode" column="postcode"/>
    </class>
    </hibernate-mapping>
      

  9.   

    <bean id="addressDao" class="org.appfuse.dao.testhibernate.TestaddressIntanceImpl"> 
      <property name="sessionFactory"> 
                <ref local="sessionFactory"/> 是这样的吧<ref name="sessionFactory" /> <property name="mappingResources"> 
    <list> 
    <value>customer.hbm.xml </value> 
    </list> 
    </property> 你的实体映射文件指定的路径不对 你在去检查看下 一般都把实体映射文件放在实体包中如:/包名/映射文件
      

  10.   

    那里我弄错了 是<ref local="sessionFactory">