-->
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.  [ 1 post ] 
Author Message
 Post subject: error with Programmatic configuration
PostPosted: Thu Jan 27, 2011 11:55 am 
Newbie

Joined: Thu Jan 27, 2011 11:40 am
Posts: 1
Hi. I have a swing application that uses hibernate to talk to a Derby database. I've had this setup for years without an issue. I've been using the following cgf file:

Code:
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
        <property name="hibernate.connection.url">jdbc:derby:C:\Program Files\myAPP\client\data\</property>
        <property name="hibernate.connection.driver_class">org.apache.derby.jdbc.EmbeddedDriver</property>
       
        <mapping resource="myapp.hbm.xml"/>
       
    </session-factory>
</hibernate-configuration>


Here's my problem. We now allow the user to install our app anywhere - meaning that the path to the database will not be know at compile time - so I can't specify it in the cfg file and tuck the file into our jar.

I reread the hibernate guide and came up with this code:

Code:
Configuration cfg = new Configuration()
.addResource( "myApp.cfg.xml" ).
.setProperty( "hibernate.dialect", "org.hibernate.dialect.DerbyDialect" )
.setProperty( "hibernate.connection.datasource", datasourceBuilder.toString() )
.setProperty( "hibernate.connection.driver_class", "org.apache.derby.jdbc.EmbeddedDriver" );

sessionFactory = cfg.buildSessionFactory();


i get the following error:

Code:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial


i've tried to research this, but I'm coming up blank. I understand that the <session-factory> element in the XML can have a name, but i didn't see anything in the http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/session-configuration.html#configuration-programmatic that discusses naming the session factory... should i have to do this? i'm not using jndi in my swing app.

thanks in advance for your help!!


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

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.