-->
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.  [ 4 posts ] 
Author Message
 Post subject: hibernate and liferay: unable to initialize alternate cfg
PostPosted: Sat Sep 24, 2005 11:45 pm 
Beginner
Beginner

Joined: Sat Sep 24, 2005 11:04 pm
Posts: 21
Argh... if anyone out there is attempting to use Liferay for Portlets with Hibernate I would like to know how to get around the previously loaded hibernate.cfg.xml embedded in Liferay (I still haven't found it but I'm guessing it's there somewhere). I've tried using the configure method when constructing a session factory to specify an alternate configuration file (renamed: 'stracker.hibernate.cfg.xml') but it seems to use the datasource configuration included in Liferay's hibernate mapping file regardless of the explicit session factory configuration. I've also followed the steps listed on Liferay's site to configure a datasource (i've tried defining the datasource in both conf/Catalina/localhost/liferay.xml and the tomcat server.xml files).

the exact code is as follows:

sessionFactory = new Configuration().configure("stracker.hibernate.cfg.xml").buildSessionFactory();

and after a suggestion from a friend, i've also tried:

sessionFactory = new Configuration().configure("/stracker.hibernate.cfg.xml").buildSessionFactory();

Both result in the stack trace listed below. This is frustrating... I'm going out later tonight and if I happen to come across some guy wearing a t-shirt with this stack trace printed on it then I think I might have to punch him in the face.

Hibernate version: 3.05

Hibernate config file:
...
<!-- Database connection settings -->
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="connection.datasource">jdbc/StrackerPortletDS</property>
...


Abbreviated trace of any exception that occurs:
org.hibernate.HibernateException: Name LiferayPool is not bound in this Context
at com.liferay.util.dao.hibernate.DSConnectionProvider.configure(DSConnectionProvider.java:56)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:80)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:362)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:60)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1004)
at org.dp.stracker.util.HibernateUtil.<clinit>(HibernateUtil.java:17)


Name and version of the database you are using: PostgreSQL


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 25, 2005 12:25 am 
Senior
Senior

Joined: Tue Aug 23, 2005 8:52 am
Posts: 181
Liferay embeds its properties in a few different locations, so ur frustration is understandable. I would try a grep on their ext.ear folder and find out if there are any occurrences of LiferayPool embedded in there. Last I remember, there was a property file(in addition to hibernate.cfg.xml) that contained the Datasource information.
Sorry cant be of more help.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 12:24 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
I would suggest a very thorough search of the classpath for any rogue copies of 'stracker.hibernate.cfg.xml' - or maybe a hibernate.properties .


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 1:50 pm 
Beginner
Beginner

Joined: Sat Sep 24, 2005 11:04 pm
Posts: 21
I've resolved the problem in case anyone else comes across this...

I defined the datasource in a separate context configuration file under the liferay/conf/Catalina/localhost directory. For example, if your portlet war is named SamplePortlet.war then you can create a file named SamplePortlet.xml in this directory containing the following context definition


<Context path="/SamplePortlet" docBase="SamplePortlet" reloadable="true" crossContext="true">

<Resource name="jdbc/SamplePortletDS" ...>
</Resource>

</Context>


Thanks for your help...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.