I'm a newbie in JNDI and Hibernate and I'm using Jboss.
I have a SAR file and i would like to access it by JNDI. My main questions at this point are:
1. I'm using the following code to create an initial context:
Code:
Hashtable environment = new Hashtable();
environment.put( Context.INITIAL_CONTEXT_FACTORY, jndiFactoryClass );
environment.put( Context.PROVIDER_URL, jndiURL );
initCtx = new InitialContext( environment );
Still, i don't know what should be my INITIAL_CONTEXT_FACTORY and PROVIDER_URL. And should these lines be in the class referenced by the INITIAL_CONTEXT_FACTORY?
2. I would also like to know a method for a client to obtain a session, without creating a new one. I think that the following will do that, but is this the best way to achieve it?
Code:
Context ctx = new InitialContext();
SessionFactory factory = (SessionFactory) ctx.lookup "java:/hibernate/HibernateFactory");
sess = factory.openSession();
Thanks very much for your time. Any valuable reference would be very appreciated...