2014-05-12 8 views
0

enter image description here 안녕 내가 JSP로 사용하여 사용자 등록 양식에 대한 간단한 웹 응용 프로그램을 만들고 내가 ExeptionMappingNotFoundException : 자원 :

여기
MappingNotFoundException: resource: user.hbm.xml not found 

을 다음 얻고있다 내 응용 프로그램을 실행할 때 최대 절전 모드로 묶는하고 발견되지 user.hbm.xml

<?xml version='1.0' encoding='UTF-8'?> 
<!DOCTYPE hibernate-configuration PUBLIC 
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> 

<!-- Generated by MyEclipse Hibernate Tools.     --> 
**hibernate.cfg.xml** 
    <hibernate-configuration> 

      <session-factory> 
      <property name="hbm2ddl.auto">update</property> 
      <property name="dialect">org.hibernate.dialect.MySQLDialect</property> 
      <property name="connection.url">jdbc:mysql://localhost:3306/employee</property> 
      <property name="connection.username">root</property> 
      <property name="connection.password"></property> 
      <property name="connection.driver_class">com.mysql.jdbc.Driver</property> 
      <property name="show_sql">true</property> 
     <mapping resource="hiber/user.hbm.xml"/> 
     </session-factory> 

    </hibernate-configuration> 

user.hbm.xml 내 코드입니다

<?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"> 

      <hibernate-mapping> 
      <class name="User" table="u400"> 
      <id name="id"> 
      <generator class="increment"></generator> 
      </id> 
      <property name="name"></property> 
      <property name="password"></property> 
      <property name="email"></property> 
      </class> 
      </hibernate-mapping> 

프로젝트 구조

type Exception report 

messageInternal Server Error 

descriptionThe server encountered an internal error that prevented it from fulfilling this request. 

exception 

org.apache.jasper.JasperException: org.hibernate.HibernateException: Could not parse configuration: /hiber/hibernate.cfg.xml 

root cause 

org.hibernate.HibernateException: Could not parse configuration: /hiber/hibernate.cfg.xml 

root cause 

org.dom4j.DocumentException: hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net 

답변

1

검사 그렇지 않으면 종속성을 확인할 수 없습니다.

+0

파일에서 hibernet 3.0 jar 및 dtd 버전을 사용 중입니다. 3. – user3598351

+1

okie..then 인코딩을 제거하려고 시도합니다. = hibernate.cfg.cml에서 인코딩 'UTF-8' –

+0

감사합니다. – user3598351

0

당신이 전체 제공하려고 할 수 나는이 예외를 제거 할 수 있습니다 그리고 난 다음 예외를 받고 사전 에서

감사를 어떻게해야 어떻게

Project 
    | 
    |-WebPages 
    | 
    |-src 
    |-hiber 
    | |-user.java 
     |-UserDao.java 
     |-user.hbm.xml 
     |-hibernate.cfg.xml 

를 다음과 같습니다 hibernate.cfg.xml에있는 user.hbm.xml의 경로. 그것은 기본적으로 일치해야 항아리 최대 절전 모드의 버전이 hibernate.cfg.xml

내부 DTD 버전과 비교

<mapping resource="hiber/user.hbm.xml"/> 
+0

내 게시물에 전체 경로를 추가했습니다. – user3598351

+0

hbm 파일은 프로젝트 구조에 따라 hiber 폴더 안에 있습니다. –

+0

나는 이것을 지금 내가 다른 exeption을 얻고있다 – user3598351

0

매핑 자원의 전체 경로를 사용하지 마십시오

<mapping resource="user.hbm.xml"/> 

대신

<mapping resource="hiber/user.hbm.xml"/> 

그 일

의 나에게 희망이 당신을 위해.

0

실수로 : - pojo/persistent 클래스의 대문자 'U'로 시작하는 "User.java"이름이 있지만 매핑 파일 "user.hbm.xml"은 작은 'u'로 시작합니다. 해결책 : - 두 이름이 같아야합니다. 예 : - "User.java"및 "User.hbm.xml". - 해피 코딩