Such as the title, is there anyone can tell how to custom ClassLoaderService in hibernate 4? I've try to define a ClassLoader, the methods overrided contains findClass, loadClass, findResource, and findResources. I set the ClassLoader as the ClassLoader of Hibernate, Environment, Application, and Resource in OSGi. There's not clearly right. The codes was following: /***********************Code Begin************************/ BootstrapServiceRegistry bootstrapServiceRegistry = new BootstrapServiceRegistryBuilder() .withHibernateClassLoader(classLoader) .withEnvironmentClassLoader(classLoader) .withApplicationClassLoader(classLoader) .withResourceClassLoader(classLoader).build(); Properties properties = configuration.getProperties(); Environment.verifyProperties(properties); ConfigurationHelper.resolvePlaceHolders(properties); final ServiceRegistry serviceRegistry = new ServiceRegistryBuilder( bootstrapServiceRegistry).applySettings(properties) .buildServiceRegistry(); configuration.setSessionFactoryObserver(new SessionFactoryObserver() { private static final long serialVersionUID = 1L; @Override public void sessionFactoryCreated(SessionFactory arg0) { // TODO Auto-generated method stub } @Override public void sessionFactoryClosed(SessionFactory arg0) { ((StandardServiceRegistryImpl) serviceRegistry).destroy(); } }); configuration.buildSessionFactory(serviceRegistry); /***********************Code End************************/ The classLoader in the codes which is defined by myself. It's fail to achieve the effect of mine, so I winna custom the ClassLoaderService. _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev