No Class Loader error during deploy
arupsarkar Sep 29, 2006 11:38 AMHi:
JBoss version 4.0.2
Jdk 1.4.2
MySql 5.0
Myeclipse ide
I have created a Hibernate capable project. I am using a service locator to identify the Hibernate Session Factory and Session using JNDI. I have created a hibernate.cfg.xml. I am also using hibernate doclet to generate jboss-service.xml, but I am getting the following error during deployment.
"org.jboss.deployment.DeploymentException: No ClassLoaders found for: net.sf.hibernate.jmx.HibernateService; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: net.sf.hibernate.jmx.HibernateService)"
Any help would be highly appreciated.
Regards
Arup
/***** Service Locator code ****/
public static SessionFactory getHibernateSessionFactory(String jndiSessionFactoryName) throws ServiceLocatorException {
SessionFactory sessionFactory = null;
try {
Context ctx = new InitialContext();
sessionFactory = (SessionFactory) ctx.lookup(jndiSessionFactoryName);
} catch (ClassCastException cce) {
throw new ServiceLocatorException(cce);
} catch (NamingException ne) {
throw new ServiceLocatorException(ne);
}
return sessionFactory;
}
public static Session getHibernateSession(String jndiSessionFactoryName) throws ServiceLocatorException {
Session session = null;
try
{
session = getHibernateSessionFactory(jndiSessionFactoryName).openSession();
}
catch (Exception e)
{
throw new ServiceLocatorException(e);
}
return session;
}
/**** code hibernate.cfg.xml *****/
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
root
jdbc:mysql://localhost:3307/test
net.sf.hibernate.dialect.MySQLDialect
Jaw
elkh0107
com.mysql.jdbc.Driver
</session-factory>
</hibernate-configuration>
/********** jboss-service.xml **********/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server>
<!-- Generated file - Do not edit! -->
jboss.jca:service=RARDeployer
com/jbossatwork/dto/CarDTO.hbm.xml
java:/hibernate/SessionFactory
java:/MySqlDS
net.sf.hibernate.dialect.MySQLDialect
false
false
net.sf.hibernate.transaction.JBossTransactionManagerLookup
/***** code of HibernateCarDAO *****************/
public class HibernateCarDAO implements CarDAO{
private static final String HIBERNATE_SESSION_FACTORY="java:comp/env/hibernate/SessionFactory";
public HibernateCarDAO()
{}
public List findAll()
{
List carList = new ArrayList();
Session session = null;
try
{
session = ServiceLocator.getHibernateSession(HIBERNATE_SESSION_FACTORY);
Criteria criteria = session.createCriteria(CarDTO.class);
carList = criteria.list();
}
catch (Exception e)
{
System.out.println(e);
}
finally
{
try
{
if (session != null) {session.close();}
}
catch (Exception e)
{
System.out.println(e);
}
}
return carList;
}
}