-->
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: Cannot get initial context from JNDI using generated DAO
PostPosted: Thu Apr 10, 2008 12:52 am 
Beginner
Beginner

Joined: Mon Mar 17, 2008 2:50 pm
Posts: 24
I have generated DAO from the hbm.xml file and use it in the web service deployed to the Tomcat 6.0.16.
Deployment went through fine but on servlet load I am getting the
Code:
SEVERE: Servlet /PdfService threw load() exception
java.lang.IllegalStateException: Could not locate SessionFactory in JNDI


Here is the code. I did some fiddling with it but nothing worked.
Code:
    protected SessionFactory getSessionFactory() {
        try {
            InitialContext ic = new InitialContext();
             return (SessionFactory) ic.lookup("java:comp/env/hibernate/SessionFactory");
        }
        catch (Exception e) {
            log.error("Could not locate SessionFactory in JNDI", e);
            throw new IllegalStateException("Could not locate SessionFactory in JNDI");
        }
    }


And here is what I have in the context.xml file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/PdfService" reloadable="true">
    <Logger className="org.apache.catalina.logger.FileLogger"
            prefix="pdf_svc_log." suffix=".log" timestamp="true"/>
    <Resource name="hibernate/SessionFactory" auth="Container"
        type="org.hibernate.SessionFactory" configuration="hibernate.cfg.xml"/>   
</Context>

If some kind soul can tell me what I am doing wrong and how to do it right, I'll be very appreciative.
Thanks.


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.