Hibernate version:
3.0.5
I have a SessionFactoryObjectFactory deployed in a jboss server (4.0). When I try to access it from an application outside the container (via JNDI lookup) I get a null SessionFactory. Here's the outside container application code:
--------------------------------
Properties jndiProps = new Properties();
jndiProps.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.jboss.naming.NamingContextFactory");
jndiProps.setProperty(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
jndiProps.setProperty(Context.PROVIDER_URL, "jnp://192.168.1.3:1100/");
/*my JDNI server is at port 1100, this is ok!*/
try {
context = new InitialContext(jndiProps);
} catch (NamingException e) {
//error
}
(SessionFactory) sf = (SessionFactory) context.lookup("java:/hibernate/SessionFactory");
System.out.println(sf); /*this code prints "null" here*/
-------------------------------------
I also have the following messages in the application console:
17:21:41,437 DEBUG SessionFactoryObjectFactory:39 - initializing class SessionFactoryObjectFactory
17:21:41,453 DEBUG SessionFactoryObjectFactory:69 - JNDI lookup: hibernate/SessionFactory
17:21:41,453 DEBUG SessionFactoryObjectFactory:145 - lookup: uid=4028818306ffb8b30106ffb8b6aa0000
17:21:41,453 WARN SessionFactoryObjectFactory:148 - Not found: 4028818306ffb8b30106ffb8b6aa0000
17:21:41,453 DEBUG SessionFactoryObjectFactory:149 - {}
-----------------------------------------
here is the jboss log for the HibernateService
17:38:39,867 INFO [HibernateServiceMBean] starting service at JNDI name: hibernate/SessionFactory
17:38:39,867 INFO [HibernateServiceMBean] service properties: {hibernate.session_factory_name=hibernate/SessionFactory, hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JBossTransactionManagerLookup, hibernate.transaction.auto_close_session=true, hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory, hibernate.connection.datasource=java:InformixDS, hibernate.transaction.flush_before_completion=true}
17:38:39,932 INFO [Environment] Hibernate 3.0.5
17:38:39,933 INFO [Environment] hibernate.properties not found
17:38:39,936 INFO [Environment] using CGLIB reflection optimizer
17:38:39,937 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
17:38:40,061 INFO [Configuration] Mapping resource: imb/logix/database/vdp/Cliente.hbm.xml
17:38:40,230 INFO [HbmBinder] Mapping class: imb.logix.database.vdp.Cliente -> clientes
17:38:40,300 INFO [Configuration] processing extends queue
17:38:40,301 INFO [Configuration] processing collection mappings
17:38:40,301 INFO [Configuration] processing association property references
17:38:40,301 INFO [Configuration] processing foreign key constraints
17:38:40,480 INFO [NamingHelper] JNDI InitialContext properties:{}
17:38:40,484 INFO [DatasourceConnectionProvider] Using datasource: java:InformixDS
17:38:40,820 INFO [SettingsFactory] RDBMS: Informix Dynamic Server, version: 9.40.UC6
17:38:40,820 INFO [SettingsFactory] JDBC driver: IBM Informix JDBC Driver for IBM Informix Dynamic Server, version: 2.21.JC6
17:38:40,852 INFO [Dialect] Using dialect: org.hibernate.dialect.InformixDialect
17:38:40,860 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
17:38:40,865 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
17:38:40,869 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
17:38:40,870 INFO [SettingsFactory] Automatic flush during beforeCompletion(): enabled
17:38:40,870 INFO [SettingsFactory] Automatic session close at end of transaction: enabled
17:38:40,872 INFO [SettingsFactory] Scrollable result sets: enabled
17:38:40,872 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
17:38:40,872 INFO [SettingsFactory] Connection release mode: null
17:38:40,874 INFO [SettingsFactory] Maximum outer join fetch depth: 5
17:38:40,874 INFO [SettingsFactory] Default batch fetch size: 1
17:38:40,874 INFO [SettingsFactory] Generate SQL with comments: disabled
17:38:40,874 INFO [SettingsFactory] Order SQL updates by primary key: disabled
17:38:40,874 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
17:38:40,880 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
17:38:40,881 INFO [SettingsFactory] Query language substitutions: {}
17:38:40,881 INFO [SettingsFactory] Second-level cache: enabled
17:38:40,881 INFO [SettingsFactory] Query cache: enabled
17:38:40,881 INFO [SettingsFactory] Cache provider: org.hibernate.cache.EhCacheProvider
17:38:40,888 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
17:38:40,888 INFO [SettingsFactory] Structured second-level cache entries: disabled
17:38:40,888 INFO [SettingsFactory] Query cache factory: org.hibernate.cache.StandardQueryCacheFactory
17:38:40,904 INFO [SettingsFactory] Statistics: disabled
17:38:40,904 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
17:38:40,906 INFO [SettingsFactory] Default entity-mode: pojo
17:38:41,080 INFO [SessionFactoryImpl] building session factory
17:38:41,098 WARN [Configurator] No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/usr/local/jboss-4.0.2/server/default/tmp/deploy/tmp15285ehcache-1.1.jar!/ehcache-failsafe.xml
17:38:41,660 INFO [SessionFactoryObjectFactory] Factory name: hibernate/SessionFactory
17:38:41,661 INFO [NamingHelper] JNDI InitialContext properties:{}
17:38:41,662 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: hibernate/SessionFactory
17:38:41,662 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
17:38:41,662 INFO [NamingHelper] JNDI InitialContext properties:{}
17:38:41,666 INFO [UpdateTimestampsCache] starting update timestamps cache at region: org.hibernate.cache.UpdateTimestampsCache
17:38:41,666 WARN [EhCacheProvider] Could not find configuration [org.hibernate.cache.UpdateTimestampsCache]; using defaults.
17:38:41,694 INFO [StandardQueryCache] starting query cache at region: org.hibernate.cache.StandardQueryCache
17:38:41,695 WARN [EhCacheProvider] Could not find configuration [org.hibernate.cache.StandardQueryCache]; using defaults.
17:38:41,696 INFO [SessionFactoryImpl] Checking 0 named queries
|