I did try this as you told but I am still getting the exception.
Anyways to get a solution to that. I think this is a widespread
problem(having gone through the forums), is there any other way. I am
also looking to test this finally on Webshpere so are there some
issues there?
On 10/17/08, jygnash <[EMAIL PROTECTED]> wrote:
>
> Hi Anoop,
>
> YOu can use the JNDI context to get the Hibernate's SessionFactory.
> 1)
> in hibernate-cfg.xml give the jndi name as below
> <hibernate-configuration>
> <session-factory name="HibernateSessionFactory">
> 2)
> in one of your startup servlet or first class handling the request for
> session factory creation (we had a start up servlet) , you can have the
> session factory created and made avialable
> try {
> //Create the SessionFactory from hibernate.cfg.xml
> sessionFactory = new Configuration().configure().buildSessionFactory();
>
> } catch (Throwable ex) {
> // Make sure you log the exception, as it might be swallowed
> System.err.println("Initial SessionFactory creation failed." + ex);
> throw new ExceptionInInitializerError(ex);
> }
>
> 3)
> //in rest of classes which needs the hibernate session factory can get it
> from JNDI
>
> InitialContext ctx = new InitialContext();
> SessionFactory sessionFactory = (SessionFactory)
> ctx.lookup("HibernateSessionFactory");
> session = sessionFactory.openSession(); //.getCurrentSession();
>
>
> hope that helps
>
> --
> View this message in context:
> http://www.nabble.com/Hibernate-and-Struts-tp19985981p20016169.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Anoop Dhanvijay
DA-IICT
"Most of man's failures were when they didn't realize how close they
were to success, when they finally gave up!"
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]