Hibernate binds the sessionfactory only to JNDI if he has a name != null, see code below.
Code:
public static void addInstance(String uid, String name, SessionFactory instance, Properties properties) {
log.debug("registered: " + uid + " (" + ( (name==null) ? "unnamed" : name ) + ')');
INSTANCES.put(uid, instance);
if (name!=null) NAMED_INSTANCES.put(name, instance);
//must add to JNDI _after_ adding to HashMaps, because some JNDI servers use serialization
if (name==null) {
log.info("Not binding factory to JNDI, no JNDI name configured");
}
else {
log.info("Factory name: " + name);
try {
Context ctx = NamingHelper.getInitialContext(properties);
NamingHelper.bind(ctx, name, instance);
log.info("Bound factory to JNDI name: " + name);
( (EventContext) ctx ).addNamingListener(name, EventContext.OBJECT_SCOPE, LISTENER);
}
catch (InvalidNameException ine) {
log.error("Invalid JNDI name: " + name, ine);
}
catch (NamingException ne) {
log.warn("Could not bind factory to JNDI", ne);
}
catch(ClassCastException cce) {
log.warn("InitialContext did not implement EventContext");
}
}
}
The fact that in your environment
settings.getSessionFactoryName() returns a String != null
means that you either set
Code:
hibernate.session_factory_name=something
or
Code:
<session-factory name="something">
property somewhere in your configuration files or
you call
Code:
settings.setSessionFactoryName(sessionFactoryName);
explicitely.