留言板

Spring context confilct

thumbnail
Zsolt - Jácint Balogh,修改在10 年前。

Spring context confilct

Junior Member 帖子: 91 加入日期: 13-10-9 最近的帖子
Hi all,

I have a strange issue.
I have two custom struts based portlet (exchange and calendar). I use spring for managing my objects.

I use @Autowired annotations in my action class. This portlets are on the same page and they work fine in case if the page is refreshed between the two deployments.
If I don't refresh the page (for example after server restart) then the first deployed portlet throws an exception:

1 example
Exchange deployed
Calendar deployed
page refresh


Caused by: org.springframework.beans.factory.BeanCreationException: 
Could not autowire field: private exchange.framework.bo.IExchangeBo exchange.portlet.action.ExchangeAction.exchangeBo; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [exchange.framework.bo.IExchangeBo] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506) [org.springframework.beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) [org.springframework.beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284) [org.springframework.beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
        ... 260 more


2 example
Calendar deployed
Exchange deployed
page refresh


Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private calendar.framework.onomastic.bo.INameDayBo calendar.portlet.action.CalendarAction.nameDayBo; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [calendar.framework.onomastic.bo.INameDayBo] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506) [org.springframework.beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) [org.springframework.beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284) [org.springframework.beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
        ... 260 more


3 example:
Calendar deployed
page refresh
Exchange deployed

Everything works fine

4 example:
Exchange deployed
page refresh
Calendar deployed

Everything works fine

In case of example 1-2 if I redeploy the first deployed portlet then everything is ok...

In the exchangeApplicationcontext.xml I have :

...
	<context:component-scan base-package="exchange">
		<context:exclude-filter type="annotation" expression="org.springframework.context.annotation.Configuration" />
	</context:component-scan>
...


In the calendarApplication.xml:

...
	<context:component-scan base-package="calendar">
		<context:exclude-filter type="annotation" expression="org.springframework.context.annotation.Configuration" />
	</context:component-scan>
...


I use Liferay 6.1.2-ce-ga3 bundeled with jboss 7

Sorry for my bad english.

Any suggestion?

Thanks,
Zsolt
thumbnail
Jan Geißler,修改在10 年前。

RE: Spring context confilct

Liferay Master 帖子: 735 加入日期: 11-7-5 最近的帖子
Do you have circular dependencies?

eg. Portlet 1 needs portlet2 as deployed Context and vice versa?

PS:

Are your Scopes other than Prototype or Singleton for your Spring Beans?
thumbnail
Zsolt - Jácint Balogh,修改在10 年前。

RE: Spring context confilct

Junior Member 帖子: 91 加入日期: 13-10-9 最近的帖子
Jan Geißler:
Do you have circular dependencies?

eg. Portlet 1 needs portlet2 as deployed Context and vice versa?

PS:

Are your Scopes other than Prototype or Singleton for your Spring Beans?



No the portlets are independents.
The spring beans are singletons.

Thanks,
Zsolti
thumbnail
Jan Geißler,修改在10 年前。

RE: Spring context confilct

Liferay Master 帖子: 735 加入日期: 11-7-5 最近的帖子
From what I can see, you are using your own Spring libraries. Is that correct? If so, try to use the ones Liferay provides (liferay-plugin-package) and add the jars as required jars. Liferay will inject these jars on deploy. Maybe it's due mixing the Spring libraries.
thumbnail
Zsolt - Jácint Balogh,修改在10 年前。

RE: Spring context confilct

Junior Member 帖子: 91 加入日期: 13-10-9 最近的帖子
Jan Geißler:
From what I can see, you are using your own Spring libraries. Is that correct? If so, try to use the ones Liferay provides (liferay-plugin-package) and add the jars as required jars. Liferay will inject these jars on deploy. Maybe it's due mixing the Spring libraries.



This is not the problem because it is working correctly if there are an refresh between the deploys.
I have my own spring module (spring version 3.1.2) independent from liferay in the jboss.