-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate + Tomcat. org.hibernate.MappingNotFoundException
PostPosted: Thu Aug 26, 2010 4:46 pm 
Newbie

Joined: Mon Jul 26, 2010 12:19 pm
Posts: 2
I have software which is worked correctly without Tomcat.

teacat.registration.ContenderUserRegistration use Hibernate. I map teacat.core.User and teacat.registration.ContenderUser (extends teacat.core.User) into db.

The structure of project:
|- teacat
|--- Main.class
|
|--- core
|------ IP.class
|------ Request.class
|------ Ticket.class
|------ Train.class
|------ User.class
|
|--- registration
|------ ContenderUser.class
|------ ContenderUserRegistration.class
|------ util
|--------- SHA1.class
|
|--- hibernate
|------ HibernateUtile.class
|
|- hibernate
|--- hibernate.cfg.xml
|--- classes
|------ user.hbm.xml

hibernate.cfg.xml:
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
   <session-factory>
           <!-- Database configuration -->
      <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
      <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost/teacat</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">stalker13</property>
        <property name="hibernate.connection.autocommit">true</property>
        <property name="show_sql">true</property>
        <property name="hibernate.hbm2ddl.auto">update</property>
      
      <!-- Mapping files -->
      <mapping resource = "hibernate/classes/user.hbm.xml"/>
      
   </session-factory>
</hibernate-configuration>


user.hbm.xml
Code:
<?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 package = "teacat.core">
   
   <class name = "User">
      
      <id name = "id" column = "c_id">
         <generator class = "native"/>
      </id>
   
      <property name = "name" type = "string" column = "c_name" unique = "true" length = "64"/>
      <property name = "login" type = "string" column = "c_login" length = "64"/>
      <property name = "password" type = "string" column = "c_password" length = "40"/>
      <property name = "email" type = "string" column = "c_email" length = "64"/>
      <property name = "register" type = "timestamp" column = "c_register"/>
      <property name = "update" type = "timestamp" column = "c_update"/>
      
      <joined-subclass name = "teacat.registration.ContenderUser" table = "ContenderUser">
         <key column = "c_id"/>
         <property name = "activate" type = "string" column = "c_activate"/>
      </joined-subclass>
   
   </class>
   
</hibernate-mapping>


I put this project into webapps/teacat in Tomcat.
Also webapps/teacat contains servlet ContenderRegistration which use teacat.core.ContenderUserRegistration.
But when I start my software, this class throws an error:

Code:
exception
javax.servlet.ServletException: Servlet execution threw an exception

root cause
java.lang.ExceptionInInitializerError
   teacat.registration.ContenderUserRegistration.isUnique(ContenderUserRegistration.java:65)
   teacat.registration.ContenderUserRegistration.checkName(ContenderUserRegistration.java:94)
   teacat.registration.ContenderUserRegistration.register(ContenderUserRegistration.java:40)
   ContenderRegistration.doPost(Unknown Source)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause
org.hibernate.MappingNotFoundException: resource: hibernate/classes/user.hbm.xml not found
   org.hibernate.cfg.Configuration.addResource(Configuration.java:665)
   org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1679)
   org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1647)
   org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1626)
   org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1600)
   org.hibernate.cfg.Configuration.configure(Configuration.java:1520)
   teacat.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:22)
   teacat.registration.ContenderUserRegistration.isUnique(ContenderUserRegistration.java:65)
   teacat.registration.ContenderUserRegistration.checkName(ContenderUserRegistration.java:94)
   teacat.registration.ContenderUserRegistration.register(ContenderUserRegistration.java:40)
   ContenderRegistration.doPost(Unknown Source)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


I hope someone can help me.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.