Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
francesco scamarcio
configure liferay datasource in spring+hibernate portlet
May 28, 2012 4:59 AM
Answer

francesco scamarcio

Rank: Regular Member

Posts: 104

Join Date: August 17, 2009

Recent Posts

i develope a portlet project using spring+hibernate( i don't use service builder) and i configure the datasource in spring xml file.

<bean id="liferayDataSource" class="org.springframework.jndi.jndiObjectFactorybean">
<property name="jndiName" value="java:comp/env/jdbc/MyLiferayPool"/>
</bean>

MyLiferayPool is the pool configured in tomcat context.xml file.

after i try to configure datasource to call the datasource defined in liferay portal-ext

<bean id="liferayDataSource"class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
<property name="targetDataSource">
<bean class="com.liferay.portal.kernel.util.InfrastructureUtil" factory-method="getDataSource" />
</property>
</bean>

if i deploy a portlet project with the tomcat up it works well, but when i stop the server and restart it (the portlet project is alredy deployed) i get a null pointer errror because the server load a spring xml of project portlet until load a portal-ext when the jndi is configured

anyone can help me?

Alguien me puede ayudar?
Subhash Shah
RE: configure liferay datasource in spring+hibernate portlet
May 28, 2012 11:53 PM
Answer

Subhash Shah

Rank: Junior Member

Posts: 77

Join Date: November 29, 2011

Recent Posts

Can you please paste exception stack trace here?

You should also check the sequence of spring and portlet context loader listener in web.xml of extracted portlet project.
francesco scamarcio
RE: configure liferay datasource in spring+hibernate portlet
May 29, 2012 3:25 AM
Answer

francesco scamarcio

Rank: Regular Member

Posts: 104

Join Date: August 17, 2009

Recent Posts

i follow this post and works well