-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Can't find SerialContextProvider
PostPosted: Mon Mar 29, 2004 2:43 pm 
Newbie

Joined: Mon Mar 29, 2004 2:40 pm
Posts: 2
Location: Colorado
I am learning Hibernate from the:

"Java Open Source Programming"

book and I have a handle on how Hibernate works but when doing their example, I get an error:

Code:
Mar 29, 2004 11:41:20 AM net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.1
Mar 29, 2004 11:41:20 AM net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Mar 29, 2004 11:41:20 AM net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Mar 29, 2004 11:41:20 AM net.sf.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Mar 29, 2004 11:41:20 AM net.sf.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Mar 29, 2004 11:41:20 AM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/jwhitlock/ContactInfo.hbm.xml
Mar 29, 2004 11:41:20 AM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: com.jwhitlock.ContactInfo -> CONTACT
Mar 29, 2004 11:41:20 AM net.sf.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: /jndi/ContactsSessionFactory
Mar 29, 2004 11:41:20 AM net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.HSQLDialect
Mar 29, 2004 11:41:21 AM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Mar 29, 2004 11:41:21 AM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 4
Mar 29, 2004 11:41:21 AM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:dbdata
Mar 29, 2004 11:41:21 AM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=sa, password=}
Mar 29, 2004 11:41:21 AM net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: Running hbm2ddl schema update
Mar 29, 2004 11:41:21 AM net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: fetching database metadata
Mar 29, 2004 11:41:24 AM net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: updating schema
Mar 29, 2004 11:41:24 AM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Mar 29, 2004 11:41:24 AM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Mar 29, 2004 11:41:24 AM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Mar 29, 2004 11:41:24 AM net.sf.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: schema update complete
Mar 29, 2004 11:41:24 AM net.sf.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:hsqldb:dbdata
Mar 29, 2004 11:41:24 AM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
Mar 29, 2004 11:41:24 AM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
Mar 29, 2004 11:41:24 AM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Mar 29, 2004 11:41:24 AM net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.HSQLDialect
Mar 29, 2004 11:41:24 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use outer join fetching: false
Mar 29, 2004 11:41:24 AM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Mar 29, 2004 11:41:24 AM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 4
Mar 29, 2004 11:41:24 AM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:dbdata
Mar 29, 2004 11:41:24 AM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=sa, password=}
Mar 29, 2004 11:41:24 AM net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
Mar 29, 2004 11:41:24 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: true
Mar 29, 2004 11:41:24 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: echoing all SQL to stdout
Mar 29, 2004 11:41:24 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Mar 29, 2004 11:41:24 AM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.ehcache.hibernate.Provider
Mar 29, 2004 11:41:24 AM net.sf.hibernate.cfg.Configuration configureCaches
INFO: instantiating and configuring caches
Mar 29, 2004 11:41:24 AM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Mar 29, 2004 11:41:24 AM net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Factory name: /jndi/ContactsSessionFactory
Mar 29, 2004 11:41:24 AM net.sf.hibernate.util.NamingHelper getInitialContext
INFO: JNDI InitialContext properties:{}
Mar 29, 2004 11:41:25 AM net.sf.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:hsqldb:dbdata
Mar 29, 2004 11:41:30 AM net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
WARNING: Could not bind factory to JNDI
javax.naming.CommunicationException: Can't find SerialContextProvider
   at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:63)
   at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:120)
   at net.sf.hibernate.util.NamingHelper.bind(NamingHelper.java:59)
   at net.sf.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
   at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:172)
   at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:739)
   at com.jwhitlock.Main.main(Main.java:23)
Hibernate: insert into CONTACT (FNAME, LNAME, PHONEAREACODE, PHONECOUNTRYCODE, PHONENUMBER, PK) values (?, ?, ?, ?, ?, ?)
Contact: com.jwhitlock.ContactInfo@97d026


I don't know how to remedy this. I had a problem before that where Hibernate couldn't find the initil context but that was fixed by adding j2ee.jar to the classpath. Anyone have any idea on what I'm doing wrong? I have code examples if needed. Thanks, Jeremy

_________________
He who listens well speaks well.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 29, 2004 2:46 pm 
Newbie

Joined: Mon Mar 29, 2004 2:40 pm
Posts: 2
Location: Colorado
Hibernate Version: 2.1.1
Database Type/Version: HSQLDB version 1.7.1

Mapping Document
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
   
<hibernate-mapping>
   <class name="com.jwhitlock.ContactInfo" table="CONTACT">
      <id name="id" column="PK">
         <generator class="increment"/>
      </id>
      
      <property name="firstName" column="FNAME" length="30"/>
      <property name="lastName" column="LNAME" length="50"/>
      
      <component name="phone">
         <property name="areaCode" column="PHONEAREACODE" length="3"/>
         <property name="countryCode" column="PHONECOUNTRYCODE" length="5"/>
         <property name="number" column="PHONENUMBER" length="15"/>
      </component>
   </class>
</hibernate-mapping>


Config Document
Code:
<?xml version='1.0' encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

   <session-factory name="/jndi/ContactsSessionFactory">
      <!-- properties -->
      <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
      <property name="hibernate.connection.url">jdbc:hsqldb:dbdata</property>
      <property name="hibernate.connection.username">sa</property>
      <property name="hibernate.connection.password"></property>
      <property name="hibernate.connection.pool_size">4</property>
      
      <property name="hibernate.dialect">net.sf.hibernate.dialect.HSQLDialect</property>
      
      <property name="hibernate.show_sql">true</property>
      
      <!-- mapping file -->
      <mapping resource="com/jwhitlock/ContactInfo.hbm.xml"/>
   </session-factory>
</hibernate-configuration>


Java Code
Code:
package com.jwhitlock;

import java.sql.SQLException;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.cfg.Configuration;
import net.sf.hibernate.tool.hbm2ddl.SchemaUpdate;

public class Main
{
   public static void main(String[] args)
   {
      Configuration config = new Configuration();
      
      try
      {
         config.configure();
         
         new SchemaUpdate(config).execute(true);
         
         SessionFactory result = config.buildSessionFactory();
         Session session = result.openSession();
         
         ContactInfo contact = new ContactInfo();
         PhoneNumber phone = new PhoneNumber();
         
         contact.setFirstName("Jeremy");
         contact.setLastName("Whitlock");
         
         phone.setCountryCode("001");
         phone.setAreaCode("999");
         phone.setNumber("999-9999");
         
         contact.setPhone(phone);
         
         try
         {
            session.save(contact);
            session.flush();
            session.connection().commit();
         }
         catch(Exception e)
         {
            try
            {
               session.connection().rollback();
            }
            catch(SQLException sqle)
            {
               sqle.printStackTrace();
            }
            catch(HibernateException he)
            {
               he.printStackTrace();
            }
            
            e.printStackTrace();
         }
         
         System.out.println("Contact: " + contact);
      }
      catch(HibernateException he)
      {
         he.printStackTrace();
      }
   }
}


Thanks, Jeremy

_________________
He who listens well speaks well.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 31, 2004 9:22 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There is something broken with you app server JNDI.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.