首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

Hibernate - Could not parse mapping document from input stream 咋回事

2012-03-21 
Hibernate --- Could not parse mapping document from input stream 怎么回事?applicationContext.xml?x

Hibernate --- Could not parse mapping document from input stream 怎么回事?
applicationContext.xml
<?xml   version= "1.0 "   encoding= "GB2312 "?>
<!DOCTYPE   beans   PUBLIC  
                "-//SPRING//DTD   BEAN//EN "  
                "http://www.springframework.org/dtd/spring-beans.dtd ">

  <beans>
          <!--数据源-->
          <bean   id= "dataSource "   class= "org.springframework.jdbc.datasource.DriverManagerDataSource "   destroy-method= "close ">
                  <property   name= "driverClassName ">
                          <value> com.microsoft.sqlserver.jdbc.SQLServerDriver </value>
                  </property>
                  <property   name= "url ">
                          <value> jdbc:sqlserver://localhost:1433;DatabaseName=IBS </value>
                  </property>
                  <property   name= "username ">
                          <value> sa </value>
                  </property>
                  <property   name= "password ">
                          <value> 168168 </value>
                  </property>
          </bean>
         
          <!--SessionFactory-->
          <bean   id= "sessionFactory "   class= "org.springframework.orm.hibernate3.LocalSessionFactoryBean ">
                <property   name= "dataSource ">
                        <ref   local= "dataSource "   />
                </property>
                <property   name= "mappingResources ">
                        <list>
                                <value> ibs/Manage_Account.hbm.xml </value>
                        </list>
                </property>
                <property   name= "hibernateProperties ">
                        <props>


                                <prop   key= "hibernate.dialect ">
                                        org.hibernate.dialect.SQLServerDialect
                                </prop>
                                <prop   key= "hibernate.show_sql "> true </prop>
                        </props>
                </property>
          </bean>
         
         
          <!--   将sessionFactory传递给dao   -->
          <bean   id= "daoTarget "   class= "ibs.IDAOImpl ">
                  <property   name= "sessionFactory ">
                          <ref   local= "sessionFactory "/>
                  </property>
          </bean>
         
        <bean   id= "transactionManager "   class= "org.springframework.orm.hibernate3.HibernateTransactionManager ">
                <property   name= "sessionFactory ">
                        <ref   local= "sessionFactory "   />
                </property>
        </bean>
       
        <bean   id= "dao "   class= "org.springframework.transaction.interceptor.TransactionProxyFactoryBean ">
                <property   name= "transactionManager ">
                        <ref   local= "transactionManager "/>
                </property>
                <property   name= "target ">
                        <ref   local= "daoTarget "/>
                </property>
                <property   name= "transactionAttributes ">
                        <props>
                                <prop   key= "reg "> PROPAGATION_REQUIRED </prop>
                        </props>
                </property>


        </bean>
       
        <!--   Action   -->
          <bean   name= "/login "   class= "ibs.loginAction "   singleton= "false ">
                <property   name= "dao ">
                        <ref   bean= "dao "/>
                </property>
        </bean>
        <bean   name= "/reg "   class= "ibs.RegAction "   singleton= "false ">
                <property   name= "dao ">
                        <ref   bean= "dao "/>
                </property>
        </bean>
  </beans>

Manage_Account.hbm.xml
<?xml   version= "1.0 "   encoding= "UTF-8 "?>
<!DOCTYPE   hibernate=mapping  
                PUBLIC   "-//Hibernate/Hibernate   Mapping   DTD   3.0//EN "
                                "hibernate-mapping-3.0.dtd ">
 
<hibernate-mapping   packcage= "ibs ">
        <class   name= "ibs.Manage_Account "   table= "Manage_Account ">
                <id   id= "ID "   type= "java.lang.Integer "   column= "ID ">
                        <ganerator   class= "indentity "/>
                </id>
                <property   name= "USERNAME "   type= "java.lang.String "   column= "USERNAME "   length= "50 ">
                </property>
                <property   name= "PASSWORD "   type= "java.lang.String "   column= "PASSWORD "length= "50 ">
                </property>
        </class>
</hibernate-mapping>

运行时出现错误:
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.InvalidMappingException:   Could   not   parse   mapping   document   from   input   stream

org.hibernate.InvalidMappingException:   Could   not   parse   mapping   document   from   input   stream

怎么回事啊?查了很多文章,试了很多办法还不是不管用!
大家帮帮忙啊,急啊!!!在线等

------解决方案--------------------


<property name= "USERNAME " type= "java.lang.String " column= "USERNAME " length= "50 ">
</property>
<property name= "PASSWORD " type= "java.lang.String " column= "PASSWORD "length= "50 ">
</property>

把其中的type= "java.lang.String "换成type= "string "试试看
[解决办法]
org.hibernate.InvalidMappingException
无效映射
[解决办法]
<id id="ID" type="java.lang.Integer" column="ID" >
<ganerator class="indentity"/ >
</id > 


是 name ="ID"
[解决办法]
同意yztommyhc:
<property name="PASSWORD" type="java.lang.String" column="PASSWORD"length="50" > 还有这边要加个空格。

应该是这里出了问题
[解决办法]
我也遇到一模一样的问题,现在还没解决。LZ现在解决没有,能否告之。
[解决办法]
通常是定义的类名,属性名不对. 

<class name= "ibs.Manage_Account " table= "Manage_Account ">
<id id= "ID " type= "java.lang.Integer " column= "ID ">
<ganerator class= "indentity "/>
</id>
<property name= "USERNAME " >
</property>
<property name= "PASSWORD " >
</property>
</class> 


可以像这样,没必要写那么多
[解决办法]
<id id= "ID " type= "java.lang.Integer " column= "ID "> 
<ganerator class= "indentity "/> 
</id> 
id 要该成name,,,还有你可以一个个的排除去检查

热点排行