-->
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.  [ 3 posts ] 
Author Message
 Post subject: Looking up SessoinFactory
PostPosted: Wed Aug 27, 2003 4:45 am 
Newbie

Joined: Wed Aug 27, 2003 4:39 am
Posts: 10
I am trying to use the Open Session In View and I have the following

1)In web.xml
<filter>
<filter-name>actionFilter</filter-name>
<filter-class>com.eg.web.action.ActionFilter</filter-class>
<init-param>
<param-name>hibernateFactory</param-name>
<param-value>hibernate/sessionFactory</param-value>
</init-param>
</filter>

2)In hibernate.cfg.xml I have
<!-- 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/myoracle</property>
<property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>
<property name="show_sql">false</property>
<property name="use_outer_join">true</property>

<!-- mapping files -->
<mapping resource="mapping.hbm.xml"/>

</session-factory>

3) In ActionFilter I use
public static final String HIBERNATE_FACTORY_JNDI_PARAM = "hibernateFactory";

/**
*/
public void init(FilterConfig filterConfig) throws ServletException
{
// Initialize hibernate
try
{
new Configuration().configure();
System.out.println("AFTER CONFIGURING ");
}
catch (HibernateException ex) { throw new ServletException(ex); }

// As good a place as any to initialize the factory
String factoryJndiName = filterConfig.getInitParameter(HIBERNATE_FACTORY_JNDI_PARAM);
if (factoryJndiName == null)
factoryJndiName = HIBERNATE_FACTORY_JNDI_DEFAULT;

try
{
Context ctx = new InitialContext();
factory = (SessionFactory)ctx.lookup(factoryJndiName);
}
catch (NamingException ex) { ex.printStackTrace();throw new ServletException(ex); }
}
I am getting the exception
javax.naming.NameNotFoundException: Name hibernate is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:811)
at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:183)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at com.softex.eg.web.action.ActionFilter.init(ActionFilter.java:78)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(Applicatio
nFilterConfig.java:254)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(Applica
tionFilterConfig.java:314)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFi
lterConfig.java:120)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.
Am I missing something. How does the session factory get bound

thanks in advance
rema


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 27, 2003 5:59 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Looks like you are trying to bind a SessionFactory to Tomcat's JNDI. This will not work, its a read only context. This is a FAQ and covered in the reference documentation, the Wiki and I guess the HibernateExamples.

Next time, look at the Hibernate log output on startup, you can see if the SessionFactory will be bound to JNDI and if it was successful.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: Re: Looking up SessoinFactory
PostPosted: Wed Oct 13, 2010 5:32 am 
Newbie

Joined: Wed Oct 13, 2010 5:25 am
Posts: 10
I spent my whole life trying not to be careless. Women and children can be careless. But not men.

_________________
cheap watches
replica watches uk
replica watches


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

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.