cancel
Showing results for 
Search instead for 
Did you mean: 

Spring component-scan not working for EAR modules

Former Member
0 Kudos

Dear all,

I've been trying to migrate a Spring MVC solution from TomCat 5.5 to SAP NetWeaver NWDI for some days now, and I believe I need some help.

I've created one Software Component with two Development Components, one Web Module and one EAR Module. I have other libraries and DCs that are referenced by my Web Module as dependencies.

The EAR component references the Web Module.

The problem is that I have 3 applicationContext-*.xml files distributed among different Development Components and inside each one I do some bean initialization. I use the "component-scan" feature to load my annotated classes with @Controller, @Repository, @Service and so on.

Unfortunately, it seems that spring will only load the beans declared inside these JAR files which I have an applicationContext-XXX.xml defined. Spring won't load any classes declared inside other Development Components that doesn't have an applicationContext file configured.

So, when I try to deploy my EAR to the server (everything till deploying works fine), I get some "org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'XXX' is defined " exceptions.

So, what am I doing wrong?

Here is some of the config files that I'm using:

Inside applicationContext-AAA.xml:


<context:annotation-config />
<context:component-scan base-package=com.xxx.AAA"/>

Inside applicationContext-BBB.xml:


<context:annotation-config />
<context:component-scan base-package=com.xxx.BBB"/>

(the same for applicationContext-CCC.xml)

Inside my web.xml:


<context-param>
	<param-name>contextConfigLocation</param-name>
	<param-value>
		classpath*:applicationContext-AAA.xml
		classpath*:applicationContext-BBB.xml
		classpath*:applicationContext-CCC.xml
		</param-value>
</context-param>

<!-- LISTENERS -->
<listener>
	<listener-class>
		org.springframework.web.context.ContextLoaderListener
	</listener-class>
</listener>

Thanks and Regards,

Rafael Zanini

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I have the same problem, do you find a solution ?