1 Reply Latest reply on May 27, 2005 8:14 PM by Derek Chen-Becker

    Jboss 4.0.2 Hibernate3, null JNDI session factory

    Wylie van den Akker Newbie

      I am deploying a HAR file with hibernate 3.0.3 and jboss 4.0.2

      Everything seems to deploy ok but when i goto retrieve the SessionFactory from the JNDI it feeds me back a null value.

      This is the code to get the sessionfactory

      SessionFactory sf = null;
       try {
       Context context = new InitialContext();
      
       Object o = context.lookup("java:/hibernate/SessionFactory");
       if(o == null) {
       log.error("SESSION FACTORY IS NULL");
       } else {
       log.error("SESSION FACTORY IS NOT NULL");
       sf = (SessionFactory)o;
       }
       s = sf.getCurrentSession();
       } catch (Exception e) {
       log.error("Error Obtaining Session Factory");
       log.error(e.toString());
       log.error("End");
       }
      






      this is the output i get on deploy and failier

      19:33:47,390 INFO [WrapperDataSourceService] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:se
      rvice=DataSourceBinding,name=/jdbc/mysql to JNDI name 'java:/jdbc/mysql'
      19:33:47,453 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=file:/C:/jboss/server/default/deploy/jmx-console.war/
      19:33:47,672 INFO [EARDeployer] Init J2EE application: file:/C:/jboss/server/default/deploy/akeso.ear/
      19:33:47,875 INFO [Environment] Hibernate 3.0.3
      19:33:47,890 INFO [Environment] hibernate.properties not found
      19:33:47,890 INFO [Environment] using CGLIB reflection optimizer
      19:33:47,890 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
      19:33:48,015 INFO [Hibernate] Using JDBC batch size : null
      19:33:48,031 INFO [Configuration] Searching for mapping documents in jar: akeso.har
      19:33:48,031 INFO [Configuration] Found mapping documents in jar: com/voltforge/akeso/dbo/client/Facility.hbm.xml
      19:33:48,172 INFO [HbmBinder] Mapping class: com.voltforge.akeso.dbo.client.Facility -> facility
      19:33:48,219 INFO [Configuration] Found mapping documents in jar: com/voltforge/akeso/dbo/client/Message.hbm.xml
      19:33:49,078 INFO [HbmBinder] Mapping class: com.voltforge.akeso.dbo.open.user -> user
      19:33:49,078 INFO [Configuration] processing extends queue
      19:33:49,078 INFO [Configuration] processing collection mappings
      19:33:49,078 INFO [HbmBinder] Mapping collection: com.voltforge.akeso.dbo.client.Patient.access_log -> patient_access_log
      19:33:49,078 INFO [HbmBinder] Mapping collection: com.voltforge.akeso.dbo.client.Patient.allergies -> patient_allergies
      19:33:49,078 INFO [HbmBinder] Mapping collection: com.voltforge.akeso.dbo.client.Patient.boardOfPharmacyReport -> patient_boar
      d_of_pharmacy_report
      19:33:49,078 INFO [HbmBinder] Mapping collection: com.voltforge.akeso.dbo.client.Patient.careProvider -> patient_care_provider
      
      19:33:49,078 INFO [HbmBinder] Mapping collection: com.voltforge.akeso.dbo.client.Patient.medicalHistory -> patient_medical_his
      tory
      19:33:49,078 INFO [HbmBinder] Mapping collection: com.voltforge.akeso.dbo.client.Patient.medication -> patient_medication
      19:33:49,078 INFO [HbmBinder] Mapping collection: com.voltforge.akeso.dbo.client.Patient.planOfCare -> patient_plan_of_care
      19:33:49,094 INFO [HbmBinder] Mapping collection: com.voltforge.akeso.dbo.client.Patient.progressNote -> patient_progress_note
      
      19:33:49,094 INFO [HbmBinder] Mapping collection: com.voltforge.akeso.dbo.client.Patient.review -> patient_review
      19:33:49,094 INFO [HbmBinder] Mapping collection: com.voltforge.akeso.dbo.client.Patient.visitHistory -> patient_visit_history
      
      19:33:49,094 INFO [HbmBinder] Mapping collection: com.voltforge.akeso.dbo.client.PatientVisitHistory.visit_date -> patient_vis
      it_date
      19:33:49,094 INFO [HbmBinder] Mapping collection: com.voltforge.akeso.dbo.open.contact.contact_request -> contact_request
      19:33:49,094 INFO [Configuration] processing association property references
      19:33:49,094 INFO [Configuration] processing foreign key constraints
      19:33:49,109 INFO [NamingHelper] JNDI InitialContext properties:{}
      19:33:49,109 INFO [DatasourceConnectionProvider] Using datasource: java:/jdbc/mysql
      19:33:49,406 INFO [SettingsFactory] RDBMS: MySQL, version: 3.23.58
      19:33:49,406 INFO [SettingsFactory] JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.0.15-ga ( $Date: 2004/0
      8/09 22:15:11 $, $Revision: 1.27.2.43 $ )
      19:33:49,437 INFO [Dialect] Using dialect: org.hibernate.dialect.MySQLDialect
      19:33:49,515 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.transaction.JTATransactionFactory
      19:33:49,515 INFO [NamingHelper] JNDI InitialContext properties:{}
      19:33:49,515 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTra
      nsactionManagerLookup
      19:33:49,531 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
      19:33:49,531 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTra
      nsactionManagerLookup
      19:33:49,531 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
      19:33:49,531 INFO [SettingsFactory] Automatic flush during beforeCompletion(): enabled
      19:33:49,531 INFO [SettingsFactory] Automatic session close at end of transaction: enabled
      19:33:49,531 INFO [SettingsFactory] JDBC batch size: 15
      19:33:49,531 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
      19:33:49,531 INFO [SettingsFactory] Scrollable result sets: enabled
      19:33:49,531 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): enabled
      19:33:49,531 INFO [SettingsFactory] Connection release mode: null
      19:33:49,531 INFO [SettingsFactory] Maximum outer join fetch depth: 2
      19:33:49,531 INFO [SettingsFactory] Default batch fetch size: 1
      19:33:49,531 INFO [SettingsFactory] Generate SQL with comments: disabled
      19:33:49,531 INFO [SettingsFactory] Order SQL updates by primary key: disabled
      19:33:49,531 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
      19:33:49,547 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
      19:33:49,547 INFO [SettingsFactory] Query language substitutions: {}
      19:33:49,547 INFO [SettingsFactory] Second-level cache: enabled
      19:33:49,547 INFO [SettingsFactory] Query cache: disabled
      19:33:49,547 INFO [SettingsFactory] Cache provider: org.hibernate.cache.HashtableCacheProvider
      19:33:49,547 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
      19:33:49,547 INFO [SettingsFactory] Structured second-level cache entries: enabled
      19:33:49,562 INFO [SettingsFactory] Echoing all SQL to stdout
      19:33:49,562 INFO [SettingsFactory] Statistics: disabled
      19:33:49,562 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
      19:33:49,578 INFO [SettingsFactory] Default entity-mode: pojo
      19:33:49,812 INFO [SessionFactoryImpl] building session factory
      19:33:51,531 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
      19:33:51,547 INFO [Dialect] Using dialect: org.hibernate.dialect.MySQLDialect
      19:33:51,547 INFO [Configuration] processing extends queue
      19:33:51,547 INFO [Configuration] processing collection mappings
      19:33:51,547 INFO [Configuration] processing association property references
      19:33:51,547 INFO [Configuration] processing foreign key constraints
      19:33:51,547 INFO [Configuration] processing extends queue
      19:33:51,547 INFO [Configuration] processing collection mappings
      19:33:51,547 INFO [Configuration] processing association property references
      19:33:51,547 INFO [Configuration] processing foreign key constraints
      19:33:51,547 INFO [SchemaExport] Running hbm2ddl schema export
      19:33:51,547 INFO [SchemaExport] exporting generated schema to database
      19:33:51,562 INFO [NamingHelper] JNDI InitialContext properties:{}
      19:33:51,562 INFO [DatasourceConnectionProvider] Using datasource: java:/jdbc/mysql
      19:33:51,859 INFO [SchemaExport] schema export complete
      19:33:51,875 INFO [Dialect] Using dialect: org.hibernate.dialect.MySQLDialect
      19:33:51,875 INFO [Configuration] processing extends queue
      19:33:51,875 INFO [Configuration] processing collection mappings
      19:33:51,875 INFO [Configuration] processing association property references
      19:33:51,875 INFO [Configuration] processing foreign key constraints
      19:33:51,875 INFO [Configuration] processing extends queue
      19:33:51,875 INFO [Configuration] processing collection mappings
      19:33:51,875 INFO [Configuration] processing association property references
      19:33:51,875 INFO [Configuration] processing foreign key constraints
      19:33:51,875 INFO [NamingHelper] JNDI InitialContext properties:{}
      19:33:51,875 INFO [SessionFactoryImpl] Checking 0 named queries
      19:33:51,875 INFO [Hibernate] SessionFactory successfully built and bound into JNDI [java:/hibernate/SessionFactory]
      19:33:51,906 INFO [TomcatDeployer] deploy, ctxPath=/akeso, warUrl=file:/C:/jboss/server/default/deploy/akeso.ear/akeso.war/
      19:33:53,453 INFO [TilesPlugin] Tiles definition factory loaded for module ''.
      19:33:53,500 INFO [ValidatorPlugIn] Loading validation rules file from '/WEB-INF/validator-rules.xml'
      19:33:53,547 INFO [ValidatorPlugIn] Loading validation rules file from '/WEB-INF/validation.xml'
      19:33:53,797 INFO [TilesPlugin] Factory already exists for module ''. The factory found is from module ''. No new creation.
      19:33:53,797 INFO [ValidatorPlugIn] Loading validation rules file from '/WEB-INF/validator-rules.xml'
      19:33:53,797 INFO [ValidatorPlugIn] Loading validation rules file from '/WEB-INF/validation.xml'
      19:33:53,953 INFO [TilesPlugin] Tiles definition factory loaded for module '/client'.
      19:33:53,953 INFO [ValidatorPlugIn] Loading validation rules file from '/WEB-INF/validator-rules.xml'
      19:33:53,953 INFO [ValidatorPlugIn] Loading validation rules file from '/WEB-INF/modules/client/validation.xml'
      19:33:54,000 INFO [TilesPlugin] Factory already exists for module '/client'. The factory found is from module '/client'. No ne
      w creation.
      19:33:54,000 INFO [ValidatorPlugIn] Loading validation rules file from '/WEB-INF/validator-rules.xml'
      19:33:54,000 INFO [ValidatorPlugIn] Loading validation rules file from '/WEB-INF/validation.xml'
      19:33:54,219 INFO [EARDeployer] Started J2EE application: file:/C:/jboss/server/default/deploy/akeso.ear/
      19:33:54,531 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-8080
      19:33:55,187 INFO [ChannelSocket] JK: ajp13 listening on /0.0.0.0:8009
      19:33:55,219 INFO [JkMain] Jk running ID=0 time=0/125 config=null
      19:33:55,234 INFO [Server] JBoss (MX MicroKernel) [4.0.2 (build: CVSTag=JBoss_4_0_2 date=200505022023)] Started in 26s:265ms
      19:40:58,844 INFO [TilesRequestProcessor] Tiles definition factory found for request processor ''.
      19:41:06,906 INFO [STDOUT] 19:41:06,906 ERROR [HibernateSession] {java.naming.factory.initial=org.jnp.interfaces.NamingContext
      Factory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces:org.jboss.naming:org.jnp.interfaces}
      19:41:06,922 WARN [SessionFactoryObjectFactory] Not found: 402881ec03f7bc1a0103f7bc222b0000
      19:41:06,922 INFO [STDOUT] 19:41:06,922 ERROR [HibernateSession] SESSION FACTORY IS NULL
      19:41:06,922 INFO [STDOUT] 19:41:06,922 ERROR [HibernateSession] Error Obtaining Session Factory
      19:41:06,922 INFO [STDOUT] 19:41:06,922 ERROR [HibernateSession] java.lang.NullPointerException
      19:41:06,937 INFO [STDOUT] 19:41:06,937 ERROR [HibernateSession] End
      





      Here is the code for my mbean

      <server>
       <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jb oss.har:service=Hibernate">
       <attribute name="DatasourceName">java:/jdbc/mysql</attribute>
       <attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
       <attribute name="CacheProviderClass">org.hibernate.cache.HashtableCacheProvider</attribute>
       <attribute name="Hbm2ddlAuto">create-drop</attribute>
       <attribute name="ShowSqlEnabled">true</attribute>
       </mbean>
      </server>
      
      



      Any ideas? Thanks in advance!