I tried using this, but I'm getting the following exception: [junit] DEBUG [main] ServiceLocator.<init>(44) | Looking up Session in JNDI [junit] INFO [main] ServiceLocator.<init>(49) | error communicating with JNDI, assuming testcase
[junit] FATAL [main] DatasourceConnectionProvider.configure(44) | Could not find datasource: jav a:comp/env/jdbc/cctdb [junit] javax.naming.NameNotFoundException: No object bound for java:comp/env/jdbc/cctdb Here's my ServiceLocator's constructor: private ServiceLocator() throws HibernateException, SQLException { // Try to lookup a JNDI Connection try { if (log.isDebugEnabled()) { log.debug("Looking up Session in JNDI"); } sf = (SessionFactory) new InitialContext().lookup(Constants.SESSION_FACTORY); } catch (NamingException ne) { if (log.isDebugEnabled()) { log.info("error communicating with JNDI, assuming testcase"); } sf = new Configuration("/hibernate.cfg.xml").configure()[0]; /* Datastore datastore = Hibernate.createDatastore(); datastore.storeClass(com.comcast.cable.dmc.itd.cct.persistence.ChangeRequest .class); datastore.storeClass(com.comcast.cable.dmc.itd.cct.persistence.ChangeRequest Detail.class); datastore.storeClass(com.comcast.cable.dmc.itd.cct.persistence.CMCFChannelMa p.class); datastore.storeClass(com.comcast.cable.dmc.itd.cct.persistence.CMCFIrt.class ); datastore.storeClass(com.comcast.cable.dmc.itd.cct.persistence.CMCFMaster.cl ass); datastore.storeClass(com.comcast.cable.dmc.itd.cct.persistence.CMCFMps.class ); datastore.storeClass(com.comcast.cable.dmc.itd.cct.persistence.Headend.class ); datastore.storeClass(com.comcast.cable.dmc.itd.cct.persistence.HSCRFMaster.c lass); datastore.storeClass(com.comcast.cable.dmc.itd.cct.persistence.HSCRFSignal.c lass); datastore.storeClass(com.comcast.cable.dmc.itd.cct.persistence.MSO.class); datastore.storeClass(com.comcast.cable.dmc.itd.cct.persistence.Role.class); datastore.storeClass(com.comcast.cable.dmc.itd.cct.persistence.User.class); datastore.storeClass(com.comcast.cable.dmc.itd.cct.persistence.ValidationRes ults.class); sf = datastore.buildSessionFactory(); */ } } And my hibernate.cfg.xml: <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration.dtd"> <hibernate-configuration> <!-- shared properties --> <property name="show_sql">false</property> <property name="use_outer_join">true</property> <property name="jta.UserTransaction"> java:comp/UserTransaction/ </property> <!-- a SessionFactory instance listed as /jndi/name --> <session-factory name="hibernate/sessionFactory"> <!-- properties for this SessionFactory only --> <property name="connection.datasource">java:comp/env/jdbc/cctdb</property> <property name="dialect">cirrus.hibernate.sql.OracleDialect</property> <!-- mapping files --> <mapping resource="com/comcast/cable/dmc/itd/cct/persistence/ChangeRequest.hbm.xml"/> <mapping resource="com/comcast/cable/dmc/itd/cct/persistence/ChangeRequestDetail.hbm. xml"/> <mapping resource="com/comcast/cable/dmc/itd/cct/persistence/CMCFChannelMap.hbm.xml"/ > <mapping resource="com/comcast/cable/dmc/itd/cct/persistence/CMCFIrt.hbm.xml"/> <mapping resource="com/comcast/cable/dmc/itd/cct/persistence/CMCFMaster.hbm.xml"/> <mapping resource="com/comcast/cable/dmc/itd/cct/persistence/CMCFMps.hbm.xml"/> <mapping resource="com/comcast/cable/dmc/itd/cct/persistence/HSCRFMaster.hbm.xml"/> <mapping resource="com/comcast/cable/dmc/itd/cct/persistence/HSCRFSignal.hbm.xml"/> <mapping resource="com/comcast/cable/dmc/itd/cct/persistence/Headend.hbm.xml"/> <mapping resource="com/comcast/cable/dmc/itd/cct/persistence/MSO.hbm.xml"/> <mapping resource="com/comcast/cable/dmc/itd/cct/persistence/Role.hbm.xml"/> <mapping resource="com/comcast/cable/dmc/itd/cct/persistence/User.hbm.xml"/> <mapping resource="com/comcast/cable/dmc/itd/cct/persistence/ValidationResults.hbm.xm l"/> </session-factory> </hibernate-configuration> > -----Original Message----- > From: Jason Carreira [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 05, 2003 11:41 AM > To: Joseph Fifield; [EMAIL PROTECTED] > Subject: RE: [Hibernate] Hibernate.cfg.xml without JNDI > > > Hi Joseph, > > Thank you very much! This works great! We're using a static member var > to hold the SessionFactory that is initialized in a static block. Is > this a common pattern for saving the SessionFactory? > > Thanks again, > > Jason > > > -----Original Message----- > > From: Joseph Fifield [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, February 05, 2003 12:21 PM > > To: [EMAIL PROTECTED] > > Subject: RE: [Hibernate] Hibernate.cfg.xml without JNDI > > > > > > Yes, it is possible. Something like this should do the trick: > > > > factory = new Configuration("/hibernate.cfg.xml").configure()[0]; > > > > Joe > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] > > > [mailto:[EMAIL PROTECTED] On > > > Behalf Of Jason Carreira > > > Sent: Wednesday, February 05, 2003 12:13 PM > > > To: [EMAIL PROTECTED] > > > Subject: [Hibernate] Hibernate.cfg.xml without JNDI > > > > > > > > > Is it possible to use hibernate.cfg.xml without JNDI? It > > > would even be enough if Hibernate.configure() would return > > > the SessionFactory in addition to binding it to the JNDI > > > context, or make it optional. > > > > > > The reason is, I'm trying to implement Junit tests that only > > > depend upon getting a database connection, without a > > > container (=JNDI provider) running. I tried using Mock > > > objects, but their MockContext doesn't seem to actually store > > > the bound objects for lookup later. I don't really want to > > > have to implement my own in-memory Context, so I'm wondering > > > why this form of configuration, by far the easiest, is so > > > limited in what it can do? > > > > > > Thanks, > > > > > > Jason Carreira > > > > > > -- > > > Jason Carreira > > > Software Architect, Notiva Corp. > > > phone: 585.240.2793 > > > fax: 585.272.8118 > > > email: [EMAIL PROTECTED] > > > --- > > > Notiva - optimizing trade relationships (tm) > > > > > > > > > > > > ------------------------------------------------------- > > > This SF.NET email is sponsored by: > > > SourceForge Enterprise Edition + IBM + LinuxWorld =omething 2 > > > See! http://www.vasoftware.com > > > _______________________________________________ > > > hibernate-devel mailing list [EMAIL PROTECTED] > > > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > > > > > > > > > > > > > > > > ------------------------------------------------------- > > This SF.NET email is sponsored by: > > SourceForge Enterprise Edition + IBM + LinuxWorld = Something > > 2 See! http://www.vasoftware.com > > _______________________________________________ > > hibernate-devel mailing list [EMAIL PROTECTED] > > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > > > > > ------------------------------------------------------- > This SF.NET email is sponsored by: > SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! > http://www.vasoftware.com > _______________________________________________ > hibernate-devel mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel