加载不同位置hibernate包产生的问题

环境:jboss4.2.3GA+hibernate3.2.4sp1



public class AnnotationConfFactory extends ConfFactory {
private final static Logger logger = Logger.getLogger(AnnotationConfFactory.class);

public AnnotationConfFactory(String hibernate_cfg_xml) {
super(hibernate_cfg_xml);
}

public void createSessionFactory() {
try {
Configuration configuration = null;
if ((hibernate_cfg_xml != null) && (hibernate_cfg_xml.length() != 0)){
configuration = new AnnotationConfiguration().configure(hibernate_cfg_xml);
}else{
configuration = new AnnotationConfiguration().configure();
}
this.sessionFactory = configuration.buildSessionFactory();
} catch (HibernateException e) {
logger.error("Hibernate Annotation start error: " + e);
}

}

}

上面这个类中,传入的构造参数String hibernate_cfg_xml="/hibernate.cfg.xml"。
做过实验:在tomcat5.5.x下没有问题。
在jboss4.2.3GA下,如果hibernate相关的jar放在项目的/WEB-INF/lib/下,则没有问题。
如果hibernate相关的jar在jboss/server/deploy/lib/目录下,则报异常:
org.hibernate.HibernateException: /hibernate.cfg.xml not found。
搞了半天没弄好,有遇到过的么?


[该贴被jacal于2009-05-07 01:31修改过]
[该贴被jacal于2009-05-07 01:31修改过]

你给hibernate.cfg.xml加上包名试验,JBoss是有这种现象,是classloader加载问题

谢谢banq
但我不知道该怎么给hibernate.cfg.xml加包名?