Loading Liferay Properties from Spring IoC container (to get jdbc connection parameters)

Posted by mox601 on Stack Overflow See other posts from Stack Overflow or by mox601
Published on 2010-01-28T09:43:52Z Indexed on 2010/04/10 9:03 UTC
Read the original article Hit count: 506

Filed under:
|
|

I'm developing some portlets for Liferay Portal 5.2.3 with bundled tomcat 6.0.18 using Spring IoC container. I need to map the User_ table used in Liferay database to an entity with Hibernate, so I need to use two different dataSources to separate the liferay db from the db used by portlets.

My jdbc.properties has to hold all connection parameters for both databases: no problem for the one used by portlets, but I am having issues determining which database uses liferay to hold its data.

My conclusion is that i should have something like this:

liferayConnection.url=jdbc:hsqldb:${liferay.home}/data/hsql/lportal

in order to get the database url dynamically loaded, according to Liferay properties found in portal-ext.properties. (Or, better, load the whole portal-ext.properties and read database properties from there).

The problem is that the placeholder is not resolved:

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'liferayDataSource' defined in class path resource [WEB-INF/applicationContext.xml]: Could not resolve placeholder 'liferay.home'

To dodge this problem I tried to load explicitly portal-ext.properties with a Spring bean:

<bean id="liferayPropertiesConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
          p:location="../../portal-ext.properties"/>

but no luck: liferay.home is not resolved but there aren't other errors.

How can I resolve the placeholder defined by Liferay? Thanks

© Stack Overflow or respective owner

Related posts about liferay

Related posts about spring