0

I have a parent application Application1 which loads beans based on Spring XML configuration.

I have child application Application2 (included/referred on Application1) with @Configuration based fully annotated spring java file.

When I deploy Application1 in tomcat, I see that none of the beans from Application2 loaded.

Am i missing anything?

I tried component-scan for Application2 in Application1's spring XML but no change noticed.

Edited XML of Application 1:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:task="http://www.springframework.org/schema/task"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context.xsd
                           http://www.springframework.org/schema/task
                           http://www.springframework.org/schema/task/spring-task-3.2.xsd">

     <context:annotation-config />
    <context:component-scan base-package="com.test.work.aspect"/>

 </beans>   

Package of @Configuration file:

com.test.work.aspect.JMXConfiguration

Edit2:

    @Configuration
    @ComponentScan(basePackages="com.test.aspect.mbean")
    @EnableAspectJAutoProxy(proxyTargetClass=true)
    @Profile("aspect")
    public class JMXConfiguration {


        @Bean
        public MyRmiRegistryFactoryBean myRmiRegistryFactoryBean(){
            return new MyRmiRegistryFactoryBean();
        }

        @Bean
        public MyConnectionServerFactoryBean myConnectionServerFactoryBean()    {
            return new MyConnectionServerFactoryBean();
        }
}
DecKno
  • 293
  • 1
  • 5
  • 21
  • component-scan should work. Post the XML portion containing component-scan, and the package that Application2's @Configuration file is contained in. – Ian Mc Feb 22 '16 at 14:58
  • @IanMc Edited the question with details. – DecKno Feb 22 '16 at 15:10
  • 1
    XML file looks good. "com.test.work.aspect" should be scanned. Can you post the configuration file containing the @Configuration annotation, to see how you define your beans? Thank you. – Ian Mc Feb 22 '16 at 15:18
  • @IanMc pasted Configuration file. Edited to be generic. Thank you – DecKno Feb 22 '16 at 15:25
  • This looks good. I suspect that @Profile is preventing the load. Are you certain that "aspect" is active? Perhaps comment out Profile line to see what happens. – Ian Mc Feb 22 '16 at 15:28
  • @IanMc. I have another application which loads this configuration. But for this specific application in question, its not working. I am certain that profile is active. Still I would double check. – DecKno Feb 22 '16 at 15:30
  • @IanMc I think it was issue with IDE. code changes not reflected even after 5 builds. Working fine now. your 3rd comment is apt.Thank you very much! – DecKno Feb 22 '16 at 15:35

0 Answers0