Hello, all.
First of all, I am using Liferay 6.0 EE SP2 in Tomcat 6.0.32.
I am trying to deploy some portlets in Liferay. These portlets are legacy code made by people who did not knew a lot about how Liferay works at the time and made, let us say, "amazing" decisions, such as to map Liferay Service Builder entity tables to new classes. These portlets are seamed by Spring and mapped to database by Hibernate. To avoid the annoying requirement of editing
context.xml (which is tiresome, error prone, easily forgettable, makes the persistence layer slow as hell etc.) I provided the Liferay datasource as a new bean...
1 <bean id="liferayDataSource"
2 class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
3 <property name="targetDataSource">
4 <bean
5 class="com.liferay.portal.kernel.util.InfrastructureUtil"
6 factory-method="getDataSource" />
7 </property>
8 </bean>
...and used this new bean as the datasource of the Entity Manager Factory:
1 <bean id="entityManagerFactory"
2 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
3 <property name="dataSource" ref="liferayDataSource"/>
4 <property name="persistenceUnitName" value="liferay-db" />
5 </bean>
If I have the Liferay running and I deploy my portlets, it runs without problem because the Liferay resources are already available. The problem is, when I restart Liferay these portlets are loaded
before the Liferay app going up, so the
InfrastructureUtil class is not even loaded yet. The dependencies are not satisfied and the plugin cannot be loaded. This problem, however, does not happen when deploying portlets generated by Plugins SDK, even when they contain services generated by Service Builder.
So, how could I solve this problem? I wonder about two possible solutions:
- Could I delay the loading of my portlet, in such a way it will be loaded after Liferay?
- Could I delay the loading of the Spring context of the portlet, or make the context loading lazy / on-demand?
Are they viable? What other solutions could I try?
Please sign in to flag this as inappropriate.