-->
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: HIBERNATE NOT BOUND, please help
PostPosted: Tue Jul 24, 2007 6:33 am 
Newbie

Joined: Tue Jul 24, 2007 5:58 am
Posts: 8
========================HibernateCarDAO.java

public class HibernateCarDAO implements CarDAO
{
private List carList;
private static final String HIBERNATE_SESSION_FACTORY="java:comp/env/hibernate/SessionFactory";

public HibernateCarDAO()
{}

public List findAll()
{
List carList = new ArrayList();
Session session = null;

try
{
session = ServiceLocator.getHibernateSession(HIBERNATE_SESSION_FACTORY);
Criteria criteria = session.createCriteria(CarDTO.class);
carList = criteria.list();
...
...
return carList;
}
}
========================ServiceLocator.java

public static SessionFactory getHibernateSessionFactory(String jndiSessionFactoryName) throws ServiceLocatorException {
SessionFactory sessionFactory = null;

try {
Context ctx = new InitialContext();
sessionFactory = (SessionFactory) ctx.lookup(jndiSessionFactoryName);

} catch (ClassCastException cce) {
throw new ServiceLocatorException(cce);
} catch (NamingException ne) {
throw new ServiceLocatorException(ne);
}

return sessionFactory;
}

public static Session getHibernateSession(String jndiSessionFactoryName) throws ServiceLocatorException {
Session session = null;

try
{
session = getHibernateSessionFactory(jndiSessionFactoryName).openSession();
}
catch (Exception e)
{
throw new ServiceLocatorException(e);
}
return session;
}
}


Last edited by lema on Tue Jul 24, 2007 6:49 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 24, 2007 6:36 am 
Newbie

Joined: Tue Jul 24, 2007 5:58 am
Posts: 8
========================jboss-web.xml
...
<resource-ref>
<res-ref-name>hibernate/SessionFactory</res-ref-name>
<jndi-name>java:/hibernate/SessionFactory</jndi-name>
</resource-ref>
...
========================hibernate-service.xml
<server>
<mbean code="org.jboss.hibernate.jmx.Hibernate"
name="jboss.har:service=Hibernate">
<attribute name="DatasourceName">java:/JBossAtWorkDS</attribute>
<attribute name="Dialect">org.hibernate.dialect.HSQLDialect</attribute>
<attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
<attribute name="CacheProviderClass">org.hibernate.cache.HashtableCacheProvider</attribute>
</mbean>
</server>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 24, 2007 6:47 am 
Newbie

Joined: Tue Jul 24, 2007 5:58 am
Posts: 8
======================this is what jboss-4.0.1 displays

15:30:31,637 INFO [STDOUT] com.jbossatwork.util.ServiceLocatorException: com.jb
ossatwork.util.ServiceLocatorException: javax.naming.NamingException: Could not
dereference object [Root exception is javax.naming.NameNotFoundException: hibern
ate not bound]



i'm working wit the examples of http://www.jbossatwork.com/downloads.html
it runs only with JDBCCarDAO.java but not with HibernateCarDAO.java though book says that it runs through HibernateCarDAO.

please, anybody help, what am i doing wrong?[/b]


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.