-->
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 mapping file not found
PostPosted: Wed Dec 06, 2006 3:54 pm 
Newbie

Joined: Wed Jul 26, 2006 1:41 pm
Posts: 18
Hi,

When i deploy my struts+hibernate application on tomcat i get the following error:

**** Initilizing HibernatePlugIn for HRIS**********
Error while initializing hibernate: Resource: org/theclass/candidate/view/Candidate.hbm.xml not found


I have hibernate.cfg.xml under WEB-INF/classes & WEB-INF/src directory

hibernate.cfg.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">

<hibernate-configuration>

<session-factory>

<!-- Database connection settings -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/theclass_TheClassDB?autoReconnect=true</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">password</property>

<!-- SQL dialect -->
<!--<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property> -->
<!-- <property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>

<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update</property>

<!-- Disable the second-level cache-->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>

<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>

<mapping resource="org/theclass/candidate/view/Candidate.hbm.xml"/>

</session-factory>

</hibernate-configuration>

Here is HibernatePlugin.java:

package org.theclass.candidate.view;

import java.net.URL;
import javax.servlet.ServletException;
import javax.servlet.ServletContext;

import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.PlugIn;
import org.apache.struts.config.ModuleConfig;


public class HibernatePlugin implements PlugIn {


private String configFilePath = "/hibernate.cfg.xml";

public static final String SESSION_FACTORY_KEY
= SessionFactory.class.getName();

private SessionFactory factory = null;

public void destroy() {
try {
factory.close();
} catch (HibernateException e) {
//log.error("unable to close factory", e);
System.out.println("Unable to close Hibernate Session Factory: " + e.getMessage());
}
} //EOF destroy

public void init(ActionServlet servlet, ModuleConfig modConfig)
throws ServletException {
System.out.println("**** Initilizing HibernatePlugIn for HRIS**********");

ServletContext context = null;
Configuration config = null;
URL url = null;


try {

//ClassLoader finds the Hibernate.cfg.xml file

url = HibernatePlugin.class.getResource(configFilePath);
context = servlet.getServletContext();
config = (new Configuration()).configure(url);
factory = config.buildSessionFactory();


//Store Hibernate Factory object in Servlet Context
context.setAttribute(SESSION_FACTORY_KEY, factory);
System.out.println("Storing SessionFactory in context");


} catch (HibernateException e) {
System.out.println("Error while initializing hibernate: " + e.getMessage());
}

System.out.println("*************************************");

} //EOF init


public void setConfigFilePath(String configPath) {
if ((configPath == null) || (configPath.trim().length() == 0)) {
throw new IllegalArgumentException(
"configFilePath cannot be blank or null.");
}

System.out.println("Setting 'configFilePath' to '" + configPath + "'...");
configFilePath = configPath;
}

} //EOF HibernatePlugIn class

What could possible be wrong. Any help would be appreciated.


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.